chargify / chargify_api_ares

A Chargify API wrapper for Ruby using ActiveResource
http://chargify.com
MIT License
161 stars 95 forks source link

Allow metafield update on a subscription via the API #85

Closed jonathansimmons closed 10 years ago

jonathansimmons commented 10 years ago

Looking here I'm seeing that metafields are valid api endpoints.

It would be great if this gem supported this.

Update

After clarification it appears these endpoints only allow get (list) and post (metafield create) endpoints. It's not yet possible to set/update the metafield of a new or existing subscription via the api. See thread and specificalyl this comment for clarity.

jeremywrowe commented 10 years ago

Thanks for the report @jonathansimmons I will take a look at adding it here shortly.

jeremywrowe commented 10 years ago

@jonathansimmons I have released a pre-release version of the gem found here:

https://rubygems.org/gems/chargify_api_ares/versions/1.1.0.pre For more information on how to use metafields please look at this commit: https://github.com/chargify/chargify_api_ares/commit/ca27f0abbfab1614fdd0848ed5f67c760a3eab19

Note this does not include updating metadata for a given subscription / customer record, but that is to come.

jonathansimmons commented 10 years ago

Sweet, though I wished I clarified that updating was a key part of what I we were looking for. Any timeline on this being completed and released? (cc: @yesthatallen)

jeremywrowe commented 10 years ago

@jonathansimmons I don't have an ETA. It is out of band work for me. I will try to get to it ASAP though. Can you explain how you want to use it so that we align on end result.

jeremywrowe commented 10 years ago

Do you want to do something like subscription.metadata(name: "something", value: "other") as it stands now I was implementing it to be a separate request.

jonathansimmons commented 10 years ago

subscription.metadata(name: "subdomain", value: "example") is exactly what we are looking for. Essentially @yesthatallen's desire is to be able to utilize a metafield for subdomain to create custom url 's in the chargify e-mails pointing our subscribers back to our internal billing pages vs the chargify hosted pages.

Forgive me though as I just re-read the docs and it's appears I was mistaken in thinking the API endpoints for updating a metafield already existed. That doesn't appear to be the case?

jeremywrowe commented 10 years ago

I think what you are looking for is metadata endpoints

jonathansimmons commented 10 years ago

Right, I'm confused as to how they don't exist. The metadata field is only useful for those using hosted pages?

jeremywrowe commented 10 years ago

We added them so that merchants can add data along side subscriptions / customers. So if you need to internally keep track of data with each subscription and don't want to build a mapping from Chargify subscription to your system you could.

jonathansimmons commented 10 years ago

Agreed, which is exactly what we want. We just don't use the hosted pages, everything is created via the Chargify API. So to me it appears without the use of hosted pages the metafields are essentially useless. For API users as least. Am I wrong?

jonathansimmons commented 10 years ago

This issue appears to have changed form "Support custom metafields" to "Allow metafield update on a subscription via the API".

For example since we use our subscriber's subdomain as a reference in chargify updating a metafield might look something like:

subscription = Chargify::Subscription.find_by_customer_reference([our_subscribers_subdomain])
subscription.metafields = {name: "subdomain", value: "[our_subscribers_subdomain]"}
subscription.save

I've updated the issue. If this is not the right place for this type of request, let me know where I can submit a proper one.

jeremywrowe commented 10 years ago

This is the right place for the request, thanks for the detail of how you want the interface to work.

jeremywrowe commented 10 years ago

Just as a status update, metadata is coming soon. I am just having some others double check the work. Please see https://github.com/chargify/chargify_api_ares/pull/86 You'll want to have a look at the subscription metadata methods added.

jonathansimmons commented 10 years ago

Nice! Thanks for the quick work man!

jeremywrowe commented 10 years ago

No problem, thanks for putting it on our radar. It should have been added from the get go. If you could pull it down and take a look at it and tell me what you think that would be great.

jeremywrowe commented 10 years ago

v1.1.0 of the gem is out! please check out the examples here and enjoy!

https://github.com/chargify/chargify_api_ares/blob/master/examples/metadata.rb