recurly 2.19.7 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +158 -110
- data/Rakefile +6 -0
- data/bin/bundle +105 -0
- data/bin/coderay +29 -0
- data/bin/console +14 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/pry +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/bin/yard +29 -0
- data/bin/yardoc +29 -0
- data/bin/yri +29 -0
- data/lib/data/ca-certificates.crt +31 -0
- data/lib/recurly/client/operations.rb +935 -0
- data/lib/recurly/client.rb +198 -0
- data/lib/recurly/errors/api_errors.rb +35 -0
- data/lib/recurly/errors/network_errors.rb +8 -0
- data/lib/recurly/errors.rb +34 -0
- data/lib/recurly/pager.rb +119 -0
- data/lib/recurly/request.rb +30 -0
- data/lib/recurly/requests/account_acquisition_updatable.rb +22 -0
- data/lib/recurly/requests/account_create_only.rb +18 -0
- data/lib/recurly/requests/account_updatable.rb +50 -0
- data/lib/recurly/requests/add_on_create.rb +38 -0
- data/lib/recurly/requests/add_on_update.rb +38 -0
- data/lib/recurly/requests/address.rb +42 -0
- data/lib/recurly/requests/billing_info_create.rb +58 -0
- data/lib/recurly/requests/coupon_create_only.rb +66 -0
- data/lib/recurly/requests/coupon_updatable.rb +30 -0
- data/lib/recurly/requests/create_account.rb +62 -0
- data/lib/recurly/requests/create_coupon.rb +90 -0
- data/lib/recurly/requests/invoice_create.rb +42 -0
- data/lib/recurly/requests/invoice_refund.rb +30 -0
- data/lib/recurly/requests/line_item_create.rb +46 -0
- data/lib/recurly/requests/plan_create.rb +66 -0
- data/lib/recurly/requests/plan_update.rb +70 -0
- data/lib/recurly/requests/shipping_address_create.rb +58 -0
- data/lib/recurly/requests/shipping_address_update.rb +62 -0
- data/lib/recurly/requests/subscription_add_on_create.rb +22 -0
- data/lib/recurly/requests/subscription_change_create.rb +42 -0
- data/lib/recurly/requests/subscription_create.rb +86 -0
- data/lib/recurly/requests/subscription_update.rb +42 -0
- data/lib/recurly/requests/update_coupon.rb +30 -0
- data/lib/recurly/resource.rb +16 -1113
- data/lib/recurly/resources/account.rb +86 -0
- data/lib/recurly/resources/account_acquisition.rb +42 -0
- data/lib/recurly/resources/account_balance.rb +22 -0
- data/lib/recurly/resources/account_note.rb +30 -0
- data/lib/recurly/resources/add_on.rb +62 -0
- data/lib/recurly/resources/address.rb +42 -0
- data/lib/recurly/resources/billing_info.rb +62 -0
- data/lib/recurly/resources/coupon.rb +110 -0
- data/lib/recurly/resources/coupon_discount.rb +22 -0
- data/lib/recurly/resources/coupon_redemption.rb +46 -0
- data/lib/recurly/resources/credit_payment.rb +62 -0
- data/lib/recurly/resources/error.rb +18 -0
- data/lib/recurly/resources/error_may_have_transaction.rb +22 -0
- data/lib/recurly/resources/invoice.rb +138 -0
- data/lib/recurly/resources/invoice_collection.rb +18 -0
- data/lib/recurly/resources/line_item.rb +166 -0
- data/lib/recurly/resources/plan.rb +86 -0
- data/lib/recurly/resources/settings.rb +18 -0
- data/lib/recurly/resources/shipping_address.rb +74 -0
- data/lib/recurly/resources/site.rb +46 -0
- data/lib/recurly/resources/subscription.rb +134 -0
- data/lib/recurly/resources/subscription_add_on.rb +42 -0
- data/lib/recurly/resources/subscription_change.rb +54 -0
- data/lib/recurly/resources/tax_info.rb +18 -0
- data/lib/recurly/resources/transaction.rb +146 -0
- data/lib/recurly/resources/unique_coupon_code.rb +38 -0
- data/lib/recurly/resources/user.rb +38 -0
- data/lib/recurly/schema/json_deserializer.rb +53 -0
- data/lib/recurly/schema/json_parser.rb +71 -0
- data/lib/recurly/schema/request_caster.rb +66 -0
- data/lib/recurly/schema/schema_factory.rb +50 -0
- data/lib/recurly/schema/schema_validator.rb +125 -0
- data/lib/recurly/schema.rb +114 -0
- data/lib/recurly/version.rb +1 -10
- data/lib/recurly.rb +14 -164
- data/recurly.gemspec +32 -0
- data/scripts/build +4 -0
- data/scripts/clean +6 -0
- data/scripts/test +3 -0
- metadata +129 -192
- data/lib/recurly/account.rb +0 -230
- data/lib/recurly/account_acquisition.rb +0 -27
- data/lib/recurly/account_balance.rb +0 -23
- data/lib/recurly/add_on.rb +0 -52
- data/lib/recurly/address.rb +0 -25
- data/lib/recurly/adjustment.rb +0 -98
- data/lib/recurly/api/errors.rb +0 -208
- data/lib/recurly/api/net_http_adapter.rb +0 -111
- data/lib/recurly/api.rb +0 -110
- data/lib/recurly/billing_info.rb +0 -133
- data/lib/recurly/business_entity.rb +0 -30
- data/lib/recurly/coupon.rb +0 -136
- data/lib/recurly/credit_payment.rb +0 -32
- data/lib/recurly/currency_percentage_tier.rb +0 -17
- data/lib/recurly/custom_field.rb +0 -15
- data/lib/recurly/custom_field_definition.rb +0 -14
- data/lib/recurly/customer_permission.rb +0 -10
- data/lib/recurly/delivery.rb +0 -19
- data/lib/recurly/dunning_campaign.rb +0 -30
- data/lib/recurly/dunning_cycle.rb +0 -18
- data/lib/recurly/entitlement.rb +0 -19
- data/lib/recurly/error.rb +0 -13
- data/lib/recurly/external_account.rb +0 -17
- data/lib/recurly/external_charge.rb +0 -20
- data/lib/recurly/external_invoice.rb +0 -26
- data/lib/recurly/external_product.rb +0 -34
- data/lib/recurly/external_product_reference.rb +0 -18
- data/lib/recurly/external_subscription.rb +0 -36
- data/lib/recurly/gateway_attribute.rb +0 -10
- data/lib/recurly/gift_card.rb +0 -85
- data/lib/recurly/helper.rb +0 -51
- data/lib/recurly/invoice.rb +0 -322
- data/lib/recurly/invoice_collection.rb +0 -14
- data/lib/recurly/invoice_template.rb +0 -14
- data/lib/recurly/item.rb +0 -36
- data/lib/recurly/js.rb +0 -14
- data/lib/recurly/juris_detail.rb +0 -15
- data/lib/recurly/measured_unit.rb +0 -16
- data/lib/recurly/money.rb +0 -120
- data/lib/recurly/note.rb +0 -14
- data/lib/recurly/percentage_tier.rb +0 -17
- data/lib/recurly/plan.rb +0 -56
- data/lib/recurly/plan_ramp_interval.rb +0 -10
- data/lib/recurly/purchase.rb +0 -238
- data/lib/recurly/redemption.rb +0 -46
- data/lib/recurly/resource/association.rb +0 -16
- data/lib/recurly/resource/errors.rb +0 -20
- data/lib/recurly/resource/pager.rb +0 -313
- data/lib/recurly/shipping_address.rb +0 -26
- data/lib/recurly/shipping_fee.rb +0 -17
- data/lib/recurly/shipping_method.rb +0 -13
- data/lib/recurly/sub_add_on_percentage_tier.rb +0 -17
- data/lib/recurly/subscription/add_ons.rb +0 -82
- data/lib/recurly/subscription.rb +0 -371
- data/lib/recurly/subscription_add_on.rb +0 -64
- data/lib/recurly/subscription_ramp_interval.rb +0 -10
- data/lib/recurly/tax_detail.rb +0 -18
- data/lib/recurly/tax_type.rb +0 -13
- data/lib/recurly/tier.rb +0 -18
- data/lib/recurly/transaction/errors.rb +0 -119
- data/lib/recurly/transaction.rb +0 -131
- data/lib/recurly/usage.rb +0 -29
- data/lib/recurly/verify.rb +0 -12
- data/lib/recurly/webhook/account_notification.rb +0 -13
- data/lib/recurly/webhook/billing_info_update_failed_notification.rb +0 -6
- data/lib/recurly/webhook/billing_info_updated_notification.rb +0 -6
- data/lib/recurly/webhook/canceled_account_notification.rb +0 -6
- data/lib/recurly/webhook/canceled_gift_card_notification.rb +0 -6
- data/lib/recurly/webhook/canceled_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/closed_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/closed_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/credit_payment_notification.rb +0 -12
- data/lib/recurly/webhook/deactivated_item_notification.rb +0 -6
- data/lib/recurly/webhook/deleted_shipping_address_notification.rb +0 -6
- data/lib/recurly/webhook/dunning_notification.rb +0 -14
- data/lib/recurly/webhook/expired_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/failed_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/failed_payment_notification.rb +0 -6
- data/lib/recurly/webhook/fraud_info_updated_notification.rb +0 -6
- data/lib/recurly/webhook/gift_card_notification.rb +0 -8
- data/lib/recurly/webhook/invoice_notification.rb +0 -12
- data/lib/recurly/webhook/item_notification.rb +0 -7
- data/lib/recurly/webhook/low_balance_gift_card_notification.rb +0 -6
- data/lib/recurly/webhook/new_account_notification.rb +0 -6
- data/lib/recurly/webhook/new_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/new_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/new_credit_payment_notification.rb +0 -6
- data/lib/recurly/webhook/new_dunning_event_notification.rb +0 -6
- data/lib/recurly/webhook/new_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/new_item_notification.rb +0 -6
- data/lib/recurly/webhook/new_shipping_address_notification.rb +0 -6
- data/lib/recurly/webhook/new_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/new_usage_notification.rb +0 -8
- data/lib/recurly/webhook/notification.rb +0 -18
- data/lib/recurly/webhook/paid_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/past_due_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/past_due_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/paused_subscription_renewal_notification.rb +0 -6
- data/lib/recurly/webhook/prerenewal_notification.rb +0 -6
- data/lib/recurly/webhook/processing_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/processing_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/processing_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/processing_payment_notification.rb +0 -6
- data/lib/recurly/webhook/purchased_gift_card_notification.rb +0 -7
- data/lib/recurly/webhook/reactivated_account_notification.rb +0 -6
- data/lib/recurly/webhook/reactivated_item_notification.rb +0 -6
- data/lib/recurly/webhook/redeemed_gift_card_notification.rb +0 -7
- data/lib/recurly/webhook/regenerated_gift_card_notification.rb +0 -6
- data/lib/recurly/webhook/renewed_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/reopened_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/reopened_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/scheduled_payment_notification.rb +0 -6
- data/lib/recurly/webhook/scheduled_subscription_pause_notification.rb +0 -6
- data/lib/recurly/webhook/scheduled_subscription_update_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_notification.rb +0 -12
- data/lib/recurly/webhook/subscription_pause_canceled_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_pause_modified_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_paused_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_resumed_notification.rb +0 -6
- data/lib/recurly/webhook/successful_payment_notification.rb +0 -6
- data/lib/recurly/webhook/successful_refund_notification.rb +0 -6
- data/lib/recurly/webhook/transaction_authorized_notification.rb +0 -6
- data/lib/recurly/webhook/transaction_notification.rb +0 -12
- data/lib/recurly/webhook/transaction_status_updated_notification.rb +0 -6
- data/lib/recurly/webhook/updated_account_notification.rb +0 -6
- data/lib/recurly/webhook/updated_balance_gift_card_notification.rb +0 -7
- data/lib/recurly/webhook/updated_gift_card_notification.rb +0 -6
- data/lib/recurly/webhook/updated_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/updated_item_notification.rb +0 -6
- data/lib/recurly/webhook/updated_shipping_address_notification.rb +0 -6
- data/lib/recurly/webhook/updated_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/void_payment_notification.rb +0 -6
- data/lib/recurly/webhook/voided_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/voided_credit_payment_notification.rb +0 -6
- data/lib/recurly/webhook.rb +0 -113
- data/lib/recurly/xml/nokogiri.rb +0 -60
- data/lib/recurly/xml/rexml.rb +0 -52
- data/lib/recurly/xml.rb +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4560816624b25f0c01b6403a22f7b6425c9b7dde31ef860544d4eb3b7bc36fc5
|
4
|
+
data.tar.gz: 154f6697035218babd3b843c820e17fd7650cc275ce1f931eb0800204b67b9ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1c15b8a70794c06a3d064c4d4b830975d6f5c4aeddfa14a7d5387294d2ecb1ea42f8e96070cf6adb4742a606ed36b2e8fd3e97c96b39688da2099ab72a5159d
|
7
|
+
data.tar.gz: bc16dd1d21814913aa3cb3e23d85bf745a14f47a4fe22ec1931171eef20adae9333f1ad990deacc27857f53a6941b361452123e97a32c697a05c19530e2d920b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Recurly Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,150 +1,198 @@
|
|
1
|
-
# Recurly
|
1
|
+
# Recurly
|
2
2
|
|
3
|
-
|
3
|
+
This gem is the ruby client for Recurly's V3 API (or "partner api"). It's currently Beta software
|
4
|
+
and is not yet an official release. Documentation for the API can be [found here](https://partner-docs.recurly.com).
|
4
5
|
|
5
|
-
|
6
|
-
[REST API](https://dev.recurly.com/docs/getting-started).
|
6
|
+
## Getting Started
|
7
7
|
|
8
|
-
|
9
|
-
to see documentation on the classes and methods available.
|
8
|
+
### Documentation
|
10
9
|
|
11
|
-
|
10
|
+
Documentation can be found at this link: [https://www.rubydoc.info/github/recurly/recurly-client-ruby/3_0_0_beta](https://www.rubydoc.info/github/recurly/recurly-client-ruby/3_0_0_beta).
|
11
|
+
This contains everything in the README as well as code-level documentation. We suggest starting there.
|
12
12
|
|
13
|
-
|
14
|
-
[Bundler](http://gembundler.com/) by adding the following line to your Gemfile:
|
13
|
+
### Installing
|
15
14
|
|
16
|
-
|
17
|
-
gem 'recurly', '~> 2.19.7'
|
18
|
-
```
|
19
|
-
|
20
|
-
Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
|
21
|
-
speed boost) if it's available and loaded in your app's environment.
|
22
|
-
|
23
|
-
## Configuration
|
15
|
+
This gem is a pre-release. In your Gemfile, add `recurly` as a dependency.
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
``` ruby
|
28
|
-
Recurly.subdomain = ENV['RECURLY_SUBDOMAIN']
|
29
|
-
Recurly.api_key = ENV['RECURLY_API_KEY']
|
17
|
+
```ruby
|
18
|
+
gem 'recurly', '3.0.0.beta.1'
|
30
19
|
```
|
31
20
|
|
32
|
-
|
33
|
-
|
34
|
-
Configure the client library with
|
35
|
-
[your API credentials](https://app.recurly.com/go/developer/api_access).
|
21
|
+
It's important that you lock on a specific version as there may be breaking changes between releases.
|
22
|
+
All beta releases will have the format `3.0.0.beta.x` until we go live.
|
36
23
|
|
37
|
-
|
38
|
-
* `RECURLY_API_KEY` is your "Private API Key" which can be found under "API Credentials" on the `api_access` admin page.
|
24
|
+
### Creating a client
|
39
25
|
|
40
|
-
|
26
|
+
Client instances are now explicitly created and referenced as opposed to V2's use of global, statically
|
27
|
+
initialized clients.
|
41
28
|
|
42
|
-
|
43
|
-
|
44
|
-
```
|
29
|
+
This makes multithreaded environments simpler and provides one location where every
|
30
|
+
operation can be found (rather than having them spread out among classes).
|
45
31
|
|
46
|
-
|
47
|
-
under "API Credentials" on the `api_access` admin page):
|
32
|
+
`Recurly::Client#new` initializes a new client. It requires an API key and a site id:
|
48
33
|
|
49
|
-
```
|
50
|
-
|
34
|
+
```ruby
|
35
|
+
API_KEY = '83749879bbde395b5fe0cc1a5abf8e5'
|
36
|
+
SITE_ID = 'dqzlv9shi7wa'
|
37
|
+
client = Recurly::Client.new(site_id: SITE_ID, api_key: API_KEY)
|
38
|
+
# You may use the subdomain instead of the site_id if you do not know the site_id
|
39
|
+
client = Recurly::Client.new(subdomain: 'mysite-prod', api_key: API_KEY)
|
40
|
+
sub = client.get_subscription(subscription_id: 'abcd123456')
|
51
41
|
```
|
52
42
|
|
53
|
-
|
54
|
-
[configure](https://docs.recurly.com/js/#configure) recurly.js with public key this way:
|
43
|
+
You can also pass the initializer a block. This will give you a client scoped for just that block:
|
55
44
|
|
56
|
-
```
|
57
|
-
|
45
|
+
```ruby
|
46
|
+
Recurly::Client.new(subdomain: 'mysite-prod', api_key: API_KEY) do |client|
|
47
|
+
sub = client.get_subscription(subscription_id: 'abcd123456')
|
48
|
+
end
|
58
49
|
```
|
59
50
|
|
60
|
-
|
61
|
-
configure the settings passed to Net::HTTP (e.g., an SSL certificates path or timeout lengths),
|
62
|
-
make sure you assign them when initializing the library:
|
51
|
+
If you only plan on using the client for more than one site, you should initialize a new client for each site.
|
63
52
|
|
64
|
-
```
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
```
|
71
|
-
|
72
|
-
To see which keys are supported for this Hash, see the `Attributes` section
|
73
|
-
of the [Net::HTTP documentation](http://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html) for your ruby version.
|
53
|
+
```ruby
|
54
|
+
# Give a `site_id`
|
55
|
+
client = Recurly::Client.new(api_key: API_KEY, site_id: SITE_ID)
|
56
|
+
# Or use the subdomain
|
57
|
+
client = Recurly::Client.new(api_key: API_KEY, subdomain: 'mysite-dev')
|
74
58
|
|
75
|
-
|
76
|
-
If you are using the client in a multi-threaded environment and require a different configuration per
|
77
|
-
thread you can use the following within the thread's context:
|
59
|
+
sub = client.get_subscription(subscription_id: 'abcd123456')
|
78
60
|
|
79
|
-
|
80
|
-
Recurly.
|
81
|
-
|
82
|
-
api_key: ENV['RECURLY_API_KEY'],
|
83
|
-
default_currency: "US"
|
84
|
-
})
|
61
|
+
# you should create a new client to connect to another site
|
62
|
+
client = Recurly::Client.new(api_key: API_KEY, subdomain: 'mysite-prod')
|
63
|
+
sub = client.get_subscription(subscription_id: 'abcd7890')
|
85
64
|
```
|
86
65
|
|
87
|
-
|
88
|
-
configuration items. For example if you do not define default_currency then Recurly.default_currency
|
89
|
-
will be used.
|
90
|
-
|
91
|
-
## Supported Ruby Versions
|
92
|
-
|
93
|
-
Recurly will support whichever versions the [Ruby maintainers are supporting](https://www.ruby-lang.org/en/downloads/branches/).
|
94
|
-
We support all versions with status `* maintenance`. We do not support `eol` versions or `preview` versions. This library
|
95
|
-
may work on EOL versions of ruby, but we may not be able to support you if you use one.
|
96
|
-
|
97
|
-
## Nokogiri Support
|
66
|
+
### Operations
|
98
67
|
|
99
|
-
|
100
|
-
|
101
|
-
|
68
|
+
The {Recurly::Client} contains every `operation` you can perform on the site as a list of methods. Each method is documented explaining
|
69
|
+
the types and descriptions for each input and return type. You can view all available operations by looking at the `Instance Methods Summary` list
|
70
|
+
on the {Recurly::Client} documentation page. Clicking a method will give you detailed information about its inputs and returns. Take the `create_account`
|
71
|
+
operation as an example: {Recurly::Client#create_account}.
|
102
72
|
|
103
|
-
|
73
|
+
### Pagination
|
104
74
|
|
105
|
-
|
106
|
-
|
75
|
+
Pagination is done by the class `Recurly::Pager`. All `list_*` methods on the client return an instance of this class.
|
76
|
+
The pager has an `each` method which accepts a block for each object in the entire list. Each page is fetched automatically
|
77
|
+
for you presenting the elements as a single enumerable.
|
107
78
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
- [stackoverflow](http://stackoverflow.com/questions/tagged/recurly)
|
115
|
-
|
116
|
-
## Contributing
|
117
|
-
|
118
|
-
Developing for the Recurly gem is easy with [Bundler](http://gembundler.com/).
|
119
|
-
|
120
|
-
Fork and clone the repository, `cd` into the directory, and, with a Ruby of your choice
|
121
|
-
(1.9.3 or greater), set up your environment.
|
79
|
+
```ruby
|
80
|
+
plans = client.list_plans()
|
81
|
+
plans.each do |plan|
|
82
|
+
puts "Plan: #{plan.id}"
|
83
|
+
end
|
84
|
+
```
|
122
85
|
|
123
|
-
|
86
|
+
You may also paginate in chunks with `each_page`.
|
124
87
|
|
125
|
-
```
|
126
|
-
|
88
|
+
```ruby
|
89
|
+
plans = client.list_plans()
|
90
|
+
plans.each_page do |data|
|
91
|
+
data.each do |plan|
|
92
|
+
puts "Plan: #{plan.id}"
|
93
|
+
end
|
94
|
+
end
|
127
95
|
```
|
128
96
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
97
|
+
Both `Pager#each` and `Pager#each_page` return Enumerators if a block is not given. This allows you to use other Enumerator methods
|
98
|
+
such as `map` or `each_with_index`.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
plans = client.list_plans()
|
102
|
+
plans.each_page.each_with_index do |data, page_num|
|
103
|
+
puts "Page Number #{page_num}"
|
104
|
+
data.each do |plan|
|
105
|
+
puts "Plan: #{plan.id}"
|
106
|
+
end
|
107
|
+
end
|
133
108
|
```
|
134
109
|
|
135
|
-
|
110
|
+
Pagination endpoints take a number of options to sort and filter the results. They can be passed in as keyword arguments.
|
111
|
+
The names, types, and descriptions of these arguments are listed in the rubydocs for each method:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
options = {
|
115
|
+
state: :active, # only active plans
|
116
|
+
sort: :updated_at,
|
117
|
+
order: :asc,
|
118
|
+
begin_time: DateTime.new(2017,1,1), # January 1st 2017,
|
119
|
+
end_time: DateTime.now
|
120
|
+
}
|
136
121
|
|
137
|
-
|
138
|
-
|
122
|
+
plans = client.list_plans(**options)
|
123
|
+
plans.each do |plan|
|
124
|
+
puts "Plan: #{plan.id}"
|
125
|
+
end
|
139
126
|
```
|
140
127
|
|
141
|
-
|
128
|
+
### Creating Resources
|
129
|
+
|
130
|
+
Currently, resources are created by passing in a `body` keyword argument in the form of a `Hash`.
|
131
|
+
This Hash must follow the schema of the documented request type. For example, the `create_plan` operation
|
132
|
+
takes a request of type {Recurly::Requests::PlanCreate}. Failing to conform to this schema will result in an argument
|
133
|
+
error.
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
require 'securerandom'
|
137
|
+
|
138
|
+
code = SecureRandom.uuid
|
139
|
+
plan_data = {
|
140
|
+
code: code,
|
141
|
+
interval_length: 1,
|
142
|
+
interval_unit: 'months',
|
143
|
+
name: code,
|
144
|
+
currencies: [
|
145
|
+
{
|
146
|
+
currency: 'USD',
|
147
|
+
setup_fee: 800,
|
148
|
+
unit_amount: 10
|
149
|
+
}
|
150
|
+
]
|
151
|
+
}
|
142
152
|
|
143
|
-
|
144
|
-
$ XML=nokogiri bundle exec rake
|
153
|
+
plan = client.create_plan(body: plan_data)
|
145
154
|
```
|
146
155
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
156
|
+
### Error Handling
|
157
|
+
|
158
|
+
This library currently throws 2 types of exceptions. {Recurly::Errors::APIError} and {Recurly::Errors::NetworkError}. See these 2 files for the types of exceptions you can catch:
|
159
|
+
|
160
|
+
1. [API Errors](./lib/recurly/errors/api_errors.rb)
|
161
|
+
2. [Network Errors](./lib/recurly/errors/network_errors.rb)
|
162
|
+
|
163
|
+
You will normally be working with {Recurly::Errors::APIError}. You can catch specific or generic versions of these exceptions. Example:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
begin
|
167
|
+
client = Recurly::Client.new(site_id: SITE_ID, api_key: API_KEY)
|
168
|
+
code = "iexistalready"
|
169
|
+
plan_data = {
|
170
|
+
code: code,
|
171
|
+
interval_length: 1,
|
172
|
+
interval_unit: 'months',
|
173
|
+
name: code,
|
174
|
+
currencies: [
|
175
|
+
{
|
176
|
+
currency: 'USD',
|
177
|
+
setup_fee: 800,
|
178
|
+
unit_amount: 10
|
179
|
+
}
|
180
|
+
]
|
181
|
+
}
|
182
|
+
|
183
|
+
plan = client.create_plan(body: plan_data)
|
184
|
+
rescue Recurly::Errors::ValidationError => ex
|
185
|
+
puts ex.inspect
|
186
|
+
#=> #<Recurly::ValidationError: Recurly::ValidationError: Code 'iexistalready' already exists>
|
187
|
+
puts ex.recurly_error.inspect
|
188
|
+
#=> #<Recurly::Error:0x007fbbdf8a32c8 @attributes={:type=>"validation", :message=>"Code 'iexistalready' already exists", :params=>[{"param"=>"code", "message"=>"'iexistalready' already exists"}]}>
|
189
|
+
puts ex.status_code
|
190
|
+
#=> 422
|
191
|
+
rescue Recurly::Errors::APIError => ex
|
192
|
+
# catch a generic api error
|
193
|
+
rescue Recurly::Errors::TimeoutError => ex
|
194
|
+
# catch a specific network error
|
195
|
+
rescue Recurly::Errors::NetworkError => ex
|
196
|
+
# catch a generic network error
|
197
|
+
end
|
198
|
+
```
|
data/Rakefile
ADDED
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|
data/bin/coderay
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'coderay' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("coderay", "coderay")
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "recurly"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/pry
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'pry' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("pry", "pry")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|