gocardless-pro 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +132 -0
  6. data/circle.yml +18 -0
  7. data/demo.rb +10 -0
  8. data/gocardless-pro.gemspec +27 -0
  9. data/lib/gocardless-pro.rb +243 -0
  10. data/lib/gocardless-pro/api_service.rb +57 -0
  11. data/lib/gocardless-pro/error.rb +42 -0
  12. data/lib/gocardless-pro/error/gocardless_error.rb +5 -0
  13. data/lib/gocardless-pro/error/invalid_api_usage_error.rb +5 -0
  14. data/lib/gocardless-pro/error/invalid_state_error.rb +5 -0
  15. data/lib/gocardless-pro/error/validation_error.rb +5 -0
  16. data/lib/gocardless-pro/list_response.rb +34 -0
  17. data/lib/gocardless-pro/paginator.rb +37 -0
  18. data/lib/gocardless-pro/request.rb +69 -0
  19. data/lib/gocardless-pro/resources/api_key.rb +62 -0
  20. data/lib/gocardless-pro/resources/creditor.rb +83 -0
  21. data/lib/gocardless-pro/resources/creditor_bank_account.rb +78 -0
  22. data/lib/gocardless-pro/resources/customer.rb +72 -0
  23. data/lib/gocardless-pro/resources/customer_bank_account.rb +80 -0
  24. data/lib/gocardless-pro/resources/event.rb +75 -0
  25. data/lib/gocardless-pro/resources/helper.rb +29 -0
  26. data/lib/gocardless-pro/resources/mandate.rb +70 -0
  27. data/lib/gocardless-pro/resources/payment.rb +86 -0
  28. data/lib/gocardless-pro/resources/payout.rb +66 -0
  29. data/lib/gocardless-pro/resources/publishable_api_key.rb +51 -0
  30. data/lib/gocardless-pro/resources/redirect_flow.rb +104 -0
  31. data/lib/gocardless-pro/resources/refund.rb +70 -0
  32. data/lib/gocardless-pro/resources/role.rb +101 -0
  33. data/lib/gocardless-pro/resources/subscription.rb +152 -0
  34. data/lib/gocardless-pro/resources/user.rb +60 -0
  35. data/lib/gocardless-pro/response.rb +77 -0
  36. data/lib/gocardless-pro/services/api_key_service.rb +130 -0
  37. data/lib/gocardless-pro/services/base_service.rb +29 -0
  38. data/lib/gocardless-pro/services/creditor_bank_account_service.rb +122 -0
  39. data/lib/gocardless-pro/services/creditor_service.rb +112 -0
  40. data/lib/gocardless-pro/services/customer_bank_account_service.rb +153 -0
  41. data/lib/gocardless-pro/services/customer_service.rb +112 -0
  42. data/lib/gocardless-pro/services/event_service.rb +80 -0
  43. data/lib/gocardless-pro/services/helper_service.rb +97 -0
  44. data/lib/gocardless-pro/services/mandate_service.rb +170 -0
  45. data/lib/gocardless-pro/services/payment_service.rb +164 -0
  46. data/lib/gocardless-pro/services/payout_service.rb +80 -0
  47. data/lib/gocardless-pro/services/publishable_api_key_service.rb +130 -0
  48. data/lib/gocardless-pro/services/redirect_flow_service.rb +96 -0
  49. data/lib/gocardless-pro/services/refund_service.rb +126 -0
  50. data/lib/gocardless-pro/services/role_service.rb +127 -0
  51. data/lib/gocardless-pro/services/subscription_service.rb +133 -0
  52. data/lib/gocardless-pro/services/user_service.rb +148 -0
  53. data/lib/gocardless-pro/version.rb +8 -0
  54. data/spec/api_service_spec.rb +69 -0
  55. data/spec/client_spec.rb +29 -0
  56. data/spec/error_spec.rb +44 -0
  57. data/spec/resources/api_key_spec.rb +85 -0
  58. data/spec/resources/creditor_bank_account_spec.rb +109 -0
  59. data/spec/resources/creditor_spec.rb +125 -0
  60. data/spec/resources/customer_bank_account_spec.rb +109 -0
  61. data/spec/resources/customer_spec.rb +127 -0
  62. data/spec/resources/event_spec.rb +113 -0
  63. data/spec/resources/helper_spec.rb +23 -0
  64. data/spec/resources/mandate_spec.rb +97 -0
  65. data/spec/resources/payment_spec.rb +129 -0
  66. data/spec/resources/payout_spec.rb +89 -0
  67. data/spec/resources/publishable_api_key_spec.rb +63 -0
  68. data/spec/resources/redirect_flow_spec.rb +97 -0
  69. data/spec/resources/refund_spec.rb +77 -0
  70. data/spec/resources/role_spec.rb +63 -0
  71. data/spec/resources/subscription_spec.rb +157 -0
  72. data/spec/resources/user_spec.rb +85 -0
  73. data/spec/response_spec.rb +79 -0
  74. data/spec/services/api_key_service_spec.rb +362 -0
  75. data/spec/services/creditor_bank_account_service_spec.rb +365 -0
  76. data/spec/services/creditor_service_spec.rb +339 -0
  77. data/spec/services/customer_bank_account_service_spec.rb +404 -0
  78. data/spec/services/customer_service_spec.rb +365 -0
  79. data/spec/services/event_service_spec.rb +172 -0
  80. data/spec/services/helper_service_spec.rb +123 -0
  81. data/spec/services/mandate_service_spec.rb +449 -0
  82. data/spec/services/payment_service_spec.rb +497 -0
  83. data/spec/services/payout_service_spec.rb +172 -0
  84. data/spec/services/publishable_api_key_service_spec.rb +336 -0
  85. data/spec/services/redirect_flow_service_spec.rb +208 -0
  86. data/spec/services/refund_service_spec.rb +279 -0
  87. data/spec/services/role_service_spec.rb +336 -0
  88. data/spec/services/subscription_service_spec.rb +488 -0
  89. data/spec/services/user_service_spec.rb +433 -0
  90. data/spec/spec_helper.rb +91 -0
  91. metadata +255 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2e33f63f8abea3896aec595f634b37a52562fbcd
4
+ data.tar.gz: 6f124e195e6d05ba7133971f8d5d9a1412292d32
5
+ SHA512:
6
+ metadata.gz: f866986ee59d10a38c4ab3299886e32bf99c17b0464a4cca7a5be7bb8184b6d97f5efd23f972cf5409e970fe7bbe42ad5e285ec3247f74b44674ec573ba3b705
7
+ data.tar.gz: efa3c4880e5d1e713d74174a8c0e703717b711a08bfdd07822cb781b7ccf408293309be9628a2de3745a0cfa78fa5dab4b7f5d8c798e2980310bff113b9ae84a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 GoCardless
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # Client for GoCardless Enterprise API
2
+
3
+
4
+ Add this line to your application's Gemfile:
5
+
6
+ ```ruby
7
+ gem 'gocardless-pro'
8
+ ```
9
+
10
+ ## Usage Examples
11
+
12
+ - In the case of a single response, the client will return you an instance of the resource
13
+ - In the case of list responses, the client will return an instance of `ListResponse`, which is enumerable.
14
+ - You can also call `#all` to get a lazily paginated list of resource that will deal with making extra API requests to paginate through all the data
15
+
16
+ ### Initialising the client
17
+
18
+ The client is initialised with the API Key ID and the API Key `key` property.
19
+
20
+ You can also pass in `environment` as `:sandbox` to make requests to the sandbox environment rather than the live one.
21
+
22
+ ```rb
23
+ @client = GoCardless::Client.new(
24
+ api_key: ENV["GOCARDLESS_API_ID"],
25
+ api_secret: ENV["GOCARDLESS_API_KEY"]
26
+ )
27
+ ```
28
+
29
+ ### GET requests
30
+
31
+ You can make a request to get a list of resources using the `list` method:
32
+
33
+ ```rb
34
+ @client.customers.list
35
+ ```
36
+
37
+ This README will use `customers` throughout but each of the resources in the API is available in this library. They are defined in [`gocardless.rb`](https://github.com/gocardless/pro-client-ruby/blob/master/lib/gocardless.rb#L87).
38
+
39
+ If you need to pass any options, the last (or in the absence of URL params, the only) argument is an options hash. This is used to pass query parameters for `GET` requests:
40
+
41
+ ```rb
42
+ @client.customers.list(limit: 400)
43
+ ```
44
+
45
+ A call to `list` returns an instance of `GoCardless::ListResponse`. This is a enumerable which lets you iterate over every item returned:
46
+
47
+ ```rb
48
+ @client.customers.list do |customer|
49
+ p customer.given_name
50
+ end
51
+ ```
52
+
53
+ In the case where a url parameter is needed, the method signature will contain required arguments:
54
+
55
+ ```rb
56
+ @client.customers.get(customers_id)
57
+ ```
58
+
59
+ As with list, the last argument can be an options hash:
60
+
61
+ ```rb
62
+ @client.customers.get(customers_id, limit: 200)
63
+ ```
64
+
65
+ ### POST/PUT Requests
66
+
67
+ For POST and PUT requests you need to pass in the body in as the last argument.
68
+
69
+ ```rb
70
+ @client.customers.create(
71
+ first_name: "Pete",
72
+ last_name: "Hamilton",
73
+ ...
74
+ )
75
+ ```
76
+
77
+ As with GET requests, if any parameters are required they come first:
78
+
79
+ ```rb
80
+ @client.customers.update(customer_id, {...})
81
+ ```
82
+
83
+ ### Custom Headers
84
+
85
+ If you need to pass in a custom header to an endpoint, you can pass in a separate hash as the last argument:
86
+
87
+ ```rb
88
+ @client.helpers.mandate({
89
+ account_number: 200000,
90
+ ...
91
+ }, {
92
+ 'Accept': 'application/pdf'
93
+ })
94
+ ```
95
+
96
+ There are very few endpoints in the API that require custom headers. Currently, the only ones that do are [helpers](https://developer.gocardless.com/pro/#api-endpoints-helpers).
97
+
98
+ ### Handling failures
99
+
100
+ When an API returns an error, the client __will raise__ an error that corresponds to the type of error. All errors subclass `GoCardless::Error`. There are four errors that could be thrown:
101
+
102
+ - `GoCardless::GoCardlessError`
103
+ - `GoCardless::InvalidApiUsageError`
104
+ - `GoCardless::InvalidStateError`
105
+ - `GoCardless::ValidationError`
106
+
107
+ These errors are fully documented in the [API documentation](https://developer.gocardless.com/pro/#overview-errors).
108
+
109
+ The error has the following methods to allow you to access the information from the API response:
110
+
111
+ - `#documentation_url`
112
+ - `#message`
113
+ - `#type`
114
+ - `#code`
115
+ - `#request_id`
116
+ - `#errors`
117
+
118
+ ## Supporting Ruby < 2.0.0
119
+ The client only supports Ruby >= 2.0.0 out of the box due to our use of
120
+ Enumerable::Lazy for lazy loading of paginated API resources.
121
+
122
+ However, support for previous ruby versions can be added using a gem such as
123
+ [backports](https://github.com/marcandre/backports).
124
+
125
+ 1. Add backports to your Gemfile
126
+ ```gem 'backports'```
127
+ 2. Require lazy enumerables
128
+ ```require 'backports/2.0.0/enumerable/lazy.rb'```
129
+
130
+ ## Contributing
131
+
132
+ This client is auto-generated from Crank, a toolchain that we hope to soon open source. Issues should for now be reported on this repository. __Please do not modify the source code yourself, your changes will be overriden!__
data/circle.yml ADDED
@@ -0,0 +1,18 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.0.0-p353
4
+
5
+ deployment:
6
+ git:
7
+ branch: master
8
+ commands:
9
+ - bundle exec yard doc
10
+ - git config user.name "Circle CI"
11
+ - git config user.email "robot+circleci@gocardless.com"
12
+ - git checkout gh-pages
13
+ - rm -r css GoCardless js
14
+ - mv doc/* .
15
+ - touch .nojekyll
16
+ - git add .
17
+ - git commit -m "[ci skip] Generate Yard Doc"
18
+ - git push origin gh-pages
data/demo.rb ADDED
@@ -0,0 +1,10 @@
1
+ require_relative 'lib/gocardless'
2
+
3
+ @client = GoCardless::Client.new(
4
+ api_key: ENV["GOCARDLESS_KEY"],
5
+ api_secret: ENV["GOCARDLESS_TOKEN"],
6
+ environment: :sandbox
7
+ )
8
+
9
+ puts "Your first customer:"
10
+ puts "-> #{@client.customers.list.first.inspect}"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gocardless-pro/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gocardless-pro"
8
+ spec.version = GoCardless::VERSION
9
+ spec.authors = %w(GoCardless)
10
+ spec.email = %w(engineering@gocardless.com)
11
+ spec.summary = %q{A gem for calling the GoCardless Pro API}
12
+ spec.homepage = "https://developer.gocardless.com/pro"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency 'rspec', '~> 3.1'
21
+ spec.add_development_dependency 'webmock', '~> 1.18'
22
+ spec.add_development_dependency 'rubocop', '~> 0.30.0'
23
+ spec.add_development_dependency 'yard', '~> 0.8.7.6'
24
+
25
+ spec.add_dependency 'faraday', '~> 0.8.9'
26
+ spec.add_dependency 'activesupport', '~> 4.1'
27
+ end
@@ -0,0 +1,243 @@
1
+ # encoding: utf-8
2
+ #
3
+ # WARNING: Do not edit by hand, this file was generated by Crank:
4
+ #
5
+ # https://github.com/gocardless/crank
6
+ #
7
+
8
+ require 'json'
9
+ require 'zlib'
10
+ require 'active_support/inflector'
11
+ require 'faraday'
12
+ require 'time'
13
+ require 'active_support/core_ext/hash/indifferent_access'
14
+
15
+ require 'uri'
16
+
17
+ module GoCardless
18
+ end
19
+
20
+ version_file = 'gocardless-pro/version'
21
+
22
+ if File.file? File.expand_path("#{version_file}.rb", File.dirname(__FILE__))
23
+ require_relative version_file
24
+ else
25
+ GoCardless::VERSION = ''
26
+ end
27
+
28
+ require_relative 'gocardless-pro/api_service'
29
+ require_relative 'gocardless-pro/list_response'
30
+ require_relative 'gocardless-pro/error'
31
+ require_relative 'gocardless-pro/error/validation_error'
32
+ require_relative 'gocardless-pro/error/gocardless_error'
33
+ require_relative 'gocardless-pro/error/invalid_api_usage_error'
34
+ require_relative 'gocardless-pro/error/invalid_state_error'
35
+ require_relative 'gocardless-pro/paginator'
36
+ require_relative 'gocardless-pro/request'
37
+ require_relative 'gocardless-pro/response'
38
+
39
+ require_relative 'gocardless-pro/resources/api_key'
40
+ require_relative 'gocardless-pro/services/api_key_service'
41
+
42
+ require_relative 'gocardless-pro/resources/creditor'
43
+ require_relative 'gocardless-pro/services/creditor_service'
44
+
45
+ require_relative 'gocardless-pro/resources/creditor_bank_account'
46
+ require_relative 'gocardless-pro/services/creditor_bank_account_service'
47
+
48
+ require_relative 'gocardless-pro/resources/customer'
49
+ require_relative 'gocardless-pro/services/customer_service'
50
+
51
+ require_relative 'gocardless-pro/resources/customer_bank_account'
52
+ require_relative 'gocardless-pro/services/customer_bank_account_service'
53
+
54
+ require_relative 'gocardless-pro/resources/event'
55
+ require_relative 'gocardless-pro/services/event_service'
56
+
57
+ require_relative 'gocardless-pro/resources/helper'
58
+ require_relative 'gocardless-pro/services/helper_service'
59
+
60
+ require_relative 'gocardless-pro/resources/mandate'
61
+ require_relative 'gocardless-pro/services/mandate_service'
62
+
63
+ require_relative 'gocardless-pro/resources/payment'
64
+ require_relative 'gocardless-pro/services/payment_service'
65
+
66
+ require_relative 'gocardless-pro/resources/payout'
67
+ require_relative 'gocardless-pro/services/payout_service'
68
+
69
+ require_relative 'gocardless-pro/resources/publishable_api_key'
70
+ require_relative 'gocardless-pro/services/publishable_api_key_service'
71
+
72
+ require_relative 'gocardless-pro/resources/redirect_flow'
73
+ require_relative 'gocardless-pro/services/redirect_flow_service'
74
+
75
+ require_relative 'gocardless-pro/resources/refund'
76
+ require_relative 'gocardless-pro/services/refund_service'
77
+
78
+ require_relative 'gocardless-pro/resources/role'
79
+ require_relative 'gocardless-pro/services/role_service'
80
+
81
+ require_relative 'gocardless-pro/resources/subscription'
82
+ require_relative 'gocardless-pro/services/subscription_service'
83
+
84
+ require_relative 'gocardless-pro/resources/user'
85
+ require_relative 'gocardless-pro/services/user_service'
86
+
87
+ module GoCardless
88
+ # A class for working with and talking to the GoCardless API
89
+ class Client
90
+ extend Forwardable
91
+
92
+ # Access to the service for api_key to make API calls
93
+ def api_keys
94
+ @api_keys ||= Services::ApiKeyService.new(@api_service)
95
+ end
96
+
97
+ # Access to the service for creditor to make API calls
98
+ def creditors
99
+ @creditors ||= Services::CreditorService.new(@api_service)
100
+ end
101
+
102
+ # Access to the service for creditor_bank_account to make API calls
103
+ def creditor_bank_accounts
104
+ @creditor_bank_accounts ||= Services::CreditorBankAccountService.new(@api_service)
105
+ end
106
+
107
+ # Access to the service for customer to make API calls
108
+ def customers
109
+ @customers ||= Services::CustomerService.new(@api_service)
110
+ end
111
+
112
+ # Access to the service for customer_bank_account to make API calls
113
+ def customer_bank_accounts
114
+ @customer_bank_accounts ||= Services::CustomerBankAccountService.new(@api_service)
115
+ end
116
+
117
+ # Access to the service for event to make API calls
118
+ def events
119
+ @events ||= Services::EventService.new(@api_service)
120
+ end
121
+
122
+ # Access to the service for helper to make API calls
123
+ def helpers
124
+ @helpers ||= Services::HelperService.new(@api_service)
125
+ end
126
+
127
+ # Access to the service for mandate to make API calls
128
+ def mandates
129
+ @mandates ||= Services::MandateService.new(@api_service)
130
+ end
131
+
132
+ # Access to the service for payment to make API calls
133
+ def payments
134
+ @payments ||= Services::PaymentService.new(@api_service)
135
+ end
136
+
137
+ # Access to the service for payout to make API calls
138
+ def payouts
139
+ @payouts ||= Services::PayoutService.new(@api_service)
140
+ end
141
+
142
+ # Access to the service for publishable_api_key to make API calls
143
+ def publishable_api_keys
144
+ @publishable_api_keys ||= Services::PublishableApiKeyService.new(@api_service)
145
+ end
146
+
147
+ # Access to the service for redirect_flow to make API calls
148
+ def redirect_flows
149
+ @redirect_flows ||= Services::RedirectFlowService.new(@api_service)
150
+ end
151
+
152
+ # Access to the service for refund to make API calls
153
+ def refunds
154
+ @refunds ||= Services::RefundService.new(@api_service)
155
+ end
156
+
157
+ # Access to the service for role to make API calls
158
+ def roles
159
+ @roles ||= Services::RoleService.new(@api_service)
160
+ end
161
+
162
+ # Access to the service for subscription to make API calls
163
+ def subscriptions
164
+ @subscriptions ||= Services::SubscriptionService.new(@api_service)
165
+ end
166
+
167
+ # Access to the service for user to make API calls
168
+ def users
169
+ @users ||= Services::UserService.new(@api_service)
170
+ end
171
+
172
+ # Get a Client configured to use HTTP Basic authentication with the GC Api
173
+ #
174
+ # @param options [Hash<Symbol,String>] configuration for creating the client
175
+ # @option options [Symbol] :environment the environment to connect to - one of `:live` or `:sandbox`.
176
+ # @option options [Symbol] :api_key the ID of the API Key
177
+ # @option options [Symbol] :api_secret the key of the API Key
178
+ # @option options [Symbol] :url the full URL used to make requests to. If you specify this, it will be used over the `environment` option.
179
+ # @return [Client] A client configured to use the API with HTTP Basic
180
+ # authentication.
181
+ #
182
+ def initialize(options)
183
+ api_key = options.delete(:api_key) || fail('No API key ID given to GoCardless Client')
184
+ api_secret = options.delete(:api_secret) || fail('No API secret given to GoCardless Client')
185
+ environment = options.delete(:environment) || :live
186
+ url = options.delete(:url) || url_for_environment(environment)
187
+ options = custom_options(options)
188
+ @api_service = ApiService.new(url, api_key, api_secret, options)
189
+ end
190
+
191
+ private
192
+
193
+ def url_for_environment(environment)
194
+ if environment === :live
195
+ 'https://api.gocardless.com'
196
+ elsif environment === :sandbox
197
+ 'https://api-sandbox.gocardless.com'
198
+ else
199
+ fail "Unknown environment key: #{environment}"
200
+ end
201
+ end
202
+
203
+ # Get customized options.
204
+ def custom_options(options)
205
+ return default_options if options.nil?
206
+
207
+ return default_options.merge(options) unless options[:default_headers]
208
+
209
+ opts = default_options.merge(options)
210
+ opts[:default_headers] = default_options[:default_headers].merge(options[:default_headers])
211
+
212
+ opts
213
+ end
214
+
215
+ # Get the default options.
216
+ def default_options
217
+ {
218
+ default_headers: {
219
+ 'GoCardless-Version' => '2014-11-03',
220
+ 'User-Agent' => "#{user_agent}",
221
+ 'Content-Type' => 'application/json'
222
+ }
223
+ }
224
+ end
225
+
226
+ def user_agent
227
+ @user_agent ||=
228
+ begin
229
+ gem_name = 'gocardless-pro'
230
+ gem_info = "#{gem_name}"
231
+ gem_info += "/v#{ GoCardless::VERSION}" if defined?(GoCardless::VERSION)
232
+ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
233
+ ruby_version = RUBY_VERSION
234
+ ruby_version += " p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)
235
+ comment = ["#{ruby_engine} #{ruby_version}"]
236
+ comment << "gocardless-pro v#{ GoCardless::VERSION}"
237
+ comment << "faraday v#{Faraday::VERSION}"
238
+ comment << RUBY_PLATFORM if defined?(RUBY_PLATFORM)
239
+ "#{gem_info} (#{comment.join('; ')})"
240
+ end
241
+ end
242
+ end
243
+ end