gocardless_pro 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 336757aa0c2b6a8259d999fff9b6c47b08a81ac9
4
- data.tar.gz: 8a9254232e7c5b5df0f3ff1cd4ee31a3a0e5c8ab
3
+ metadata.gz: d5ca1431d78a49ff26580c465b4c27535e05e6f6
4
+ data.tar.gz: 30a188b5a480cfb0c1f279460bfd30ee0a89d575
5
5
  SHA512:
6
- metadata.gz: d06593be915e27b49c3a227492380e92d81b5461a6dc16c4ab094d3c45640bf8405a036890e0cb98ef1194533f05bc74ea92a2c2ac9fdcd07726b0423a09818d
7
- data.tar.gz: 6d515b60b723a53c24145fdd55c75fb0de95ab6618977e2055e612ca76da8178e8a570d5da66590ae6793bb7c750ee9389dc3629bfb186b774a4ce8e2a1d69bf
6
+ metadata.gz: 9b34fdd08aa1052d048fe9e64a424b74d5562aeccd151fb5669b3fd3982d699ba5f9d921e39f0add6efc08006da072ead01d6f1f6272a58ac04e07a315fb94f7
7
+ data.tar.gz: 79d98680c2cfd629c2dff5408107257ac593eda10e2d0f2aa5de0e7b8da8390b3765113d66cb1343fbd6cd7db1e66da7d3b4d09ff81f78a75e0c2390f8c9572f
@@ -0,0 +1,6 @@
1
+ module GoCardlessPro
2
+ # Thrown when something goes wrong with the request to the API
3
+ # and we don\'t get a proper response from the GC API
4
+ class ApiError < Error
5
+ end
6
+ end
@@ -68,15 +68,22 @@ module GoCardlessPro
68
68
  valid_link_keys = %w(default_eur_payout_account default_gbp_payout_account )
69
69
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
70
70
 
71
- Struct.new(
71
+ links_class = Struct.new(
72
72
  *{
73
73
 
74
74
  default_eur_payout_account: '',
75
75
 
76
76
  default_gbp_payout_account: ''
77
77
 
78
- }.keys.sort
79
- ).new(*valid_links.sort.map(&:last))
78
+ }.keys
79
+ ) do
80
+ def initialize(hash)
81
+ hash.each do |key, val|
82
+ send("#{key}=", val)
83
+ end
84
+ end
85
+ end
86
+ links_class.new(valid_links)
80
87
  end
81
88
 
82
89
  # Provides the resource as a hash of all it's readable attributes
@@ -67,13 +67,20 @@ module GoCardlessPro
67
67
  valid_link_keys = %w(creditor )
68
68
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
69
69
 
70
- Struct.new(
70
+ links_class = Struct.new(
71
71
  *{
72
72
 
73
73
  creditor: ''
74
74
 
75
- }.keys.sort
76
- ).new(*valid_links.sort.map(&:last))
75
+ }.keys
76
+ ) do
77
+ def initialize(hash)
78
+ hash.each do |key, val|
79
+ send("#{key}=", val)
80
+ end
81
+ end
82
+ end
83
+ links_class.new(valid_links)
77
84
  end
78
85
 
79
86
  # Provides the resource as a hash of all it's readable attributes
@@ -39,6 +39,8 @@ module GoCardlessPro
39
39
 
40
40
  attr_reader :id
41
41
 
42
+ attr_reader :language
43
+
42
44
  attr_reader :metadata
43
45
 
44
46
  attr_reader :postal_code
@@ -60,6 +62,7 @@ module GoCardlessPro
60
62
  @family_name = object['family_name']
61
63
  @given_name = object['given_name']
62
64
  @id = object['id']
65
+ @language = object['language']
63
66
  @metadata = object['metadata']
64
67
  @postal_code = object['postal_code']
65
68
  @region = object['region']
@@ -67,13 +67,20 @@ module GoCardlessPro
67
67
  valid_link_keys = %w(customer )
68
68
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
69
69
 
70
- Struct.new(
70
+ links_class = Struct.new(
71
71
  *{
72
72
 
73
73
  customer: ''
74
74
 
75
- }.keys.sort
76
- ).new(*valid_links.sort.map(&:last))
75
+ }.keys
76
+ ) do
77
+ def initialize(hash)
78
+ hash.each do |key, val|
79
+ send("#{key}=", val)
80
+ end
81
+ end
82
+ end
83
+ links_class.new(valid_links)
77
84
  end
78
85
 
79
86
  # Provides the resource as a hash of all it's readable attributes
@@ -51,7 +51,7 @@ module GoCardlessPro
51
51
  valid_link_keys = %w(mandate new_customer_bank_account parent_event payment payout previous_customer_bank_account refund subscription )
52
52
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
53
53
 
54
- Struct.new(
54
+ links_class = Struct.new(
55
55
  *{
56
56
 
57
57
  mandate: '',
@@ -70,8 +70,15 @@ module GoCardlessPro
70
70
 
71
71
  subscription: ''
72
72
 
73
- }.keys.sort
74
- ).new(*valid_links.sort.map(&:last))
73
+ }.keys
74
+ ) do
75
+ def initialize(hash)
76
+ hash.each do |key, val|
77
+ send("#{key}=", val)
78
+ end
79
+ end
80
+ end
81
+ links_class.new(valid_links)
75
82
  end
76
83
 
77
84
  # Provides the resource as a hash of all it's readable attributes
@@ -56,15 +56,22 @@ module GoCardlessPro
56
56
  valid_link_keys = %w(creditor customer_bank_account )
57
57
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
58
58
 
59
- Struct.new(
59
+ links_class = Struct.new(
60
60
  *{
61
61
 
62
62
  creditor: '',
63
63
 
64
64
  customer_bank_account: ''
65
65
 
66
- }.keys.sort
67
- ).new(*valid_links.sort.map(&:last))
66
+ }.keys
67
+ ) do
68
+ def initialize(hash)
69
+ hash.each do |key, val|
70
+ send("#{key}=", val)
71
+ end
72
+ end
73
+ end
74
+ links_class.new(valid_links)
68
75
  end
69
76
 
70
77
  # Provides the resource as a hash of all it's readable attributes
@@ -67,7 +67,7 @@ module GoCardlessPro
67
67
  valid_link_keys = %w(creditor mandate payout subscription )
68
68
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
69
69
 
70
- Struct.new(
70
+ links_class = Struct.new(
71
71
  *{
72
72
 
73
73
  creditor: '',
@@ -78,8 +78,15 @@ module GoCardlessPro
78
78
 
79
79
  subscription: ''
80
80
 
81
- }.keys.sort
82
- ).new(*valid_links.sort.map(&:last))
81
+ }.keys
82
+ ) do
83
+ def initialize(hash)
84
+ hash.each do |key, val|
85
+ send("#{key}=", val)
86
+ end
87
+ end
88
+ end
89
+ links_class.new(valid_links)
83
90
  end
84
91
 
85
92
  # Provides the resource as a hash of all it's readable attributes
@@ -53,15 +53,22 @@ module GoCardlessPro
53
53
  valid_link_keys = %w(creditor creditor_bank_account )
54
54
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
55
55
 
56
- Struct.new(
56
+ links_class = Struct.new(
57
57
  *{
58
58
 
59
59
  creditor: '',
60
60
 
61
61
  creditor_bank_account: ''
62
62
 
63
- }.keys.sort
64
- ).new(*valid_links.sort.map(&:last))
63
+ }.keys
64
+ ) do
65
+ def initialize(hash)
66
+ hash.each do |key, val|
67
+ send("#{key}=", val)
68
+ end
69
+ end
70
+ end
71
+ links_class.new(valid_links)
65
72
  end
66
73
 
67
74
  # Provides the resource as a hash of all it's readable attributes
@@ -83,7 +83,7 @@ module GoCardlessPro
83
83
  valid_link_keys = %w(creditor customer customer_bank_account mandate )
84
84
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
85
85
 
86
- Struct.new(
86
+ links_class = Struct.new(
87
87
  *{
88
88
 
89
89
  creditor: '',
@@ -94,8 +94,15 @@ module GoCardlessPro
94
94
 
95
95
  mandate: ''
96
96
 
97
- }.keys.sort
98
- ).new(*valid_links.sort.map(&:last))
97
+ }.keys
98
+ ) do
99
+ def initialize(hash)
100
+ hash.each do |key, val|
101
+ send("#{key}=", val)
102
+ end
103
+ end
104
+ end
105
+ links_class.new(valid_links)
99
106
  end
100
107
 
101
108
  # Provides the resource as a hash of all it's readable attributes
@@ -56,13 +56,20 @@ module GoCardlessPro
56
56
  valid_link_keys = %w(payment )
57
57
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
58
58
 
59
- Struct.new(
59
+ links_class = Struct.new(
60
60
  *{
61
61
 
62
62
  payment: ''
63
63
 
64
- }.keys.sort
65
- ).new(*valid_links.sort.map(&:last))
64
+ }.keys
65
+ ) do
66
+ def initialize(hash)
67
+ hash.each do |key, val|
68
+ send("#{key}=", val)
69
+ end
70
+ end
71
+ end
72
+ links_class.new(valid_links)
66
73
  end
67
74
 
68
75
  # Provides the resource as a hash of all it's readable attributes
@@ -144,13 +144,20 @@ module GoCardlessPro
144
144
  valid_link_keys = %w(mandate )
145
145
  valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
146
146
 
147
- Struct.new(
147
+ links_class = Struct.new(
148
148
  *{
149
149
 
150
150
  mandate: ''
151
151
 
152
- }.keys.sort
153
- ).new(*valid_links.sort.map(&:last))
152
+ }.keys
153
+ ) do
154
+ def initialize(hash)
155
+ hash.each do |key, val|
156
+ send("#{key}=", val)
157
+ end
158
+ end
159
+ end
160
+ links_class.new(valid_links)
154
161
  end
155
162
 
156
163
  # Provides the resource as a hash of all it's readable attributes
@@ -4,5 +4,5 @@ end
4
4
 
5
5
  module GoCardlessPro
6
6
  # Current version of the GC gem
7
- VERSION = '1.0.1'
7
+ VERSION = '1.0.2'
8
8
  end
@@ -30,6 +30,7 @@ require_relative 'gocardless_pro/error/validation_error'
30
30
  require_relative 'gocardless_pro/error/gocardless_error'
31
31
  require_relative 'gocardless_pro/error/invalid_api_usage_error'
32
32
  require_relative 'gocardless_pro/error/invalid_state_error'
33
+ require_relative 'gocardless_pro/error/api_error'
33
34
  require_relative 'gocardless_pro/paginator'
34
35
  require_relative 'gocardless_pro/request'
35
36
  require_relative 'gocardless_pro/response'
@@ -50,6 +50,10 @@ describe GoCardlessPro::Resources::Customer do
50
50
 
51
51
 
52
52
 
53
+ "language" => "language-input",
54
+
55
+
56
+
53
57
  "metadata" => "metadata-input",
54
58
 
55
59
 
@@ -112,6 +116,10 @@ describe GoCardlessPro::Resources::Customer do
112
116
 
113
117
 
114
118
 
119
+ expect(resource.language).to eq("language-input")
120
+
121
+
122
+
115
123
  expect(resource.metadata).to eq("metadata-input")
116
124
 
117
125
 
@@ -73,7 +73,21 @@ describe GoCardlessPro::Response do
73
73
  end
74
74
  end
75
75
 
76
- context "when the resonse is an invalid invalid state error" do
76
+ context "when the response isn't JSON" do
77
+ let(:raw_response) do
78
+ double("response",
79
+ headers: {},
80
+ status: 400,
81
+ body: '',
82
+ )
83
+ end
84
+
85
+ it "raises an ApiError" do
86
+ expect { response.body }.to raise_error(GoCardlessPro::ApiError)
87
+ end
88
+ end
89
+
90
+ context "when the response is an invalid state error" do
77
91
  let(:raw_response) do
78
92
  double("response",
79
93
  headers: default_headers,
@@ -30,6 +30,7 @@ describe GoCardlessPro::Services::CustomersService do
30
30
  "family_name" => "family_name-input",
31
31
  "given_name" => "given_name-input",
32
32
  "id" => "id-input",
33
+ "language" => "language-input",
33
34
  "metadata" => "metadata-input",
34
35
  "postal_code" => "postal_code-input",
35
36
  "region" => "region-input",
@@ -53,6 +54,7 @@ describe GoCardlessPro::Services::CustomersService do
53
54
  "family_name" => "family_name-input",
54
55
  "given_name" => "given_name-input",
55
56
  "id" => "id-input",
57
+ "language" => "language-input",
56
58
  "metadata" => "metadata-input",
57
59
  "postal_code" => "postal_code-input",
58
60
  "region" => "region-input",
@@ -74,6 +76,7 @@ describe GoCardlessPro::Services::CustomersService do
74
76
  "family_name" => "family_name-input",
75
77
  "given_name" => "given_name-input",
76
78
  "id" => "id-input",
79
+ "language" => "language-input",
77
80
  "metadata" => "metadata-input",
78
81
  "postal_code" => "postal_code-input",
79
82
  "region" => "region-input",
@@ -137,6 +140,7 @@ describe GoCardlessPro::Services::CustomersService do
137
140
  "family_name" => "family_name-input",
138
141
  "given_name" => "given_name-input",
139
142
  "id" => "id-input",
143
+ "language" => "language-input",
140
144
  "metadata" => "metadata-input",
141
145
  "postal_code" => "postal_code-input",
142
146
  "region" => "region-input",
@@ -201,6 +205,10 @@ describe GoCardlessPro::Services::CustomersService do
201
205
 
202
206
 
203
207
 
208
+ expect(get_list_response.records.first.language).to eq("language-input")
209
+
210
+
211
+
204
212
  expect(get_list_response.records.first.metadata).to eq("metadata-input")
205
213
 
206
214
 
@@ -240,6 +248,7 @@ describe GoCardlessPro::Services::CustomersService do
240
248
  "family_name" => "family_name-input",
241
249
  "given_name" => "given_name-input",
242
250
  "id" => "id-input",
251
+ "language" => "language-input",
243
252
  "metadata" => "metadata-input",
244
253
  "postal_code" => "postal_code-input",
245
254
  "region" => "region-input",
@@ -269,6 +278,7 @@ describe GoCardlessPro::Services::CustomersService do
269
278
  "family_name" => "family_name-input",
270
279
  "given_name" => "given_name-input",
271
280
  "id" => "id-input",
281
+ "language" => "language-input",
272
282
  "metadata" => "metadata-input",
273
283
  "postal_code" => "postal_code-input",
274
284
  "region" => "region-input",
@@ -319,6 +329,7 @@ describe GoCardlessPro::Services::CustomersService do
319
329
  "family_name" => "family_name-input",
320
330
  "given_name" => "given_name-input",
321
331
  "id" => "id-input",
332
+ "language" => "language-input",
322
333
  "metadata" => "metadata-input",
323
334
  "postal_code" => "postal_code-input",
324
335
  "region" => "region-input",
@@ -358,6 +369,7 @@ describe GoCardlessPro::Services::CustomersService do
358
369
  "family_name" => "family_name-input",
359
370
  "given_name" => "given_name-input",
360
371
  "id" => "id-input",
372
+ "language" => "language-input",
361
373
  "metadata" => "metadata-input",
362
374
  "postal_code" => "postal_code-input",
363
375
  "region" => "region-input",
@@ -416,6 +428,7 @@ describe GoCardlessPro::Services::CustomersService do
416
428
  "family_name" => "family_name-input",
417
429
  "given_name" => "given_name-input",
418
430
  "id" => "id-input",
431
+ "language" => "language-input",
419
432
  "metadata" => "metadata-input",
420
433
  "postal_code" => "postal_code-input",
421
434
  "region" => "region-input",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gocardless_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -105,6 +105,7 @@ files:
105
105
  - lib/gocardless_pro/api_service.rb
106
106
  - lib/gocardless_pro/client.rb
107
107
  - lib/gocardless_pro/error.rb
108
+ - lib/gocardless_pro/error/api_error.rb
108
109
  - lib/gocardless_pro/error/gocardless_error.rb
109
110
  - lib/gocardless_pro/error/invalid_api_usage_error.rb
110
111
  - lib/gocardless_pro/error/invalid_state_error.rb
@@ -193,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  version: '0'
194
195
  requirements: []
195
196
  rubyforge_project:
196
- rubygems_version: 2.4.1
197
+ rubygems_version: 2.4.6
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: A gem for calling the GoCardless Pro API