This gem was initially made using XML as data format to comunicate with Chargify API because there was a problem on casting date fields in the response json.
Since we are planning to add more endpoints that do not exist in XML format, it was required to setup the json data format in order to keep the same structure on all endpoints.
This was done by setting UTC as the default timezone (chargify provides the dates with timezone included) and activating both JSON parse_json_times and ActiveSupport's use_standard_json_time_format. Those three settings enables the dates coming from Chargify API to be parsed properly as an DateTime ruby object.
Beyond that, the setup for VCR got improved by creating a new cassette for each spec and hiding sensitive information from the cassettes.
Setup
Have a chargify subdomain up and running
Build the gem locally gem build chargify_wrapper.gemspec
Install the gem locally gem install 'chargify_wrapper' --local chargify_wrapper-0.3.0.gem
Q & A
The specs should run normally
Run a simple script that uses the gem to fetch a subscription from your subdomain and set it to be delayed cancel. This can be undone after running the script on chargify panel
Run an irb on your console
irb
Paste the following script, replacing needed data
require 'chargify_wrapper'
ChargifyWrapper.configure do |config|
config.subdomain = 'your-subdomain' # like blinkbid-local
config.api_key = 'your-api-key' # same as set on blinkbid-app. you can get from rails credentials:show -e local
end
subscription = ChargifyWrapper::Subscription.find(SUBSCRIPTION_ID) # an existing chargify subscription id
subscription.delayed_cancel(reason: 'test', code: 'test')
Both rerquests should work as expected, finding the subscription and setting it to be cancelled
N/A
Feature
This gem was initially made using XML as data format to comunicate with Chargify API because there was a problem on casting date fields in the response json. Since we are planning to add more endpoints that do not exist in XML format, it was required to setup the json data format in order to keep the same structure on all endpoints.
This was done by setting
UTC
as the default timezone (chargify provides the dates with timezone included) and activating both JSONparse_json_times
and ActiveSupport'suse_standard_json_time_format
. Those three settings enables the dates coming from Chargify API to be parsed properly as an DateTime ruby object.Beyond that, the setup for VCR got improved by creating a new cassette for each spec and hiding sensitive information from the cassettes.
Setup
gem build chargify_wrapper.gemspec
gem install 'chargify_wrapper' --local chargify_wrapper-0.3.0.gem
Q & A
Run an irb on your console
Paste the following script, replacing needed data
Both rerquests should work as expected, finding the subscription and setting it to be cancelled