gocardless_pro 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -0
  3. data/README.md +71 -28
  4. data/gocardless_pro.gemspec +1 -1
  5. data/lib/gocardless_pro/api_service.rb +4 -2
  6. data/lib/gocardless_pro/client.rb +2 -1
  7. data/lib/gocardless_pro/error.rb +12 -1
  8. data/lib/gocardless_pro/resources/mandate.rb +3 -0
  9. data/lib/gocardless_pro/resources/payout.rb +3 -0
  10. data/lib/gocardless_pro/resources/redirect_flow.rb +15 -14
  11. data/lib/gocardless_pro/services/bank_details_lookups_service.rb +10 -0
  12. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +5 -2
  13. data/lib/gocardless_pro/services/creditors_service.rb +5 -2
  14. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +7 -3
  15. data/lib/gocardless_pro/services/customers_service.rb +5 -2
  16. data/lib/gocardless_pro/services/events_service.rb +2 -1
  17. data/lib/gocardless_pro/services/mandate_pdfs_service.rb +2 -1
  18. data/lib/gocardless_pro/services/mandates_service.rb +10 -5
  19. data/lib/gocardless_pro/services/payments_service.rb +11 -6
  20. data/lib/gocardless_pro/services/payouts_service.rb +2 -1
  21. data/lib/gocardless_pro/services/redirect_flows_service.rb +6 -3
  22. data/lib/gocardless_pro/services/refunds_service.rb +5 -2
  23. data/lib/gocardless_pro/services/subscriptions_service.rb +7 -3
  24. data/lib/gocardless_pro/version.rb +1 -1
  25. data/spec/api_response_spec.rb +4 -4
  26. data/spec/api_service_spec.rb +41 -43
  27. data/spec/client_spec.rb +2 -2
  28. data/spec/error_spec.rb +27 -18
  29. data/spec/resources/bank_details_lookup_spec.rb +19 -34
  30. data/spec/resources/creditor_bank_account_spec.rb +54 -99
  31. data/spec/resources/creditor_spec.rb +66 -115
  32. data/spec/resources/customer_bank_account_spec.rb +54 -99
  33. data/spec/resources/customer_spec.rb +71 -138
  34. data/spec/resources/event_spec.rb +74 -107
  35. data/spec/resources/mandate_pdf_spec.rb +15 -26
  36. data/spec/resources/mandate_spec.rb +54 -87
  37. data/spec/resources/payment_spec.rb +70 -119
  38. data/spec/resources/payout_spec.rb +50 -79
  39. data/spec/resources/redirect_flow_spec.rb +58 -95
  40. data/spec/resources/refund_spec.rb +42 -75
  41. data/spec/resources/subscription_spec.rb +82 -155
  42. data/spec/response_spec.rb +45 -46
  43. data/spec/services/bank_details_lookups_service_spec.rb +55 -60
  44. data/spec/services/creditor_bank_accounts_service_spec.rb +303 -347
  45. data/spec/services/creditors_service_spec.rb +290 -333
  46. data/spec/services/customer_bank_accounts_service_spec.rb +332 -380
  47. data/spec/services/customers_service_spec.rb +347 -400
  48. data/spec/services/events_service_spec.rb +154 -184
  49. data/spec/services/mandate_pdfs_service_spec.rb +52 -57
  50. data/spec/services/mandates_service_spec.rb +374 -410
  51. data/spec/services/payments_service_spec.rb +404 -461
  52. data/spec/services/payouts_service_spec.rb +161 -184
  53. data/spec/services/redirect_flows_service_spec.rb +188 -205
  54. data/spec/services/refunds_service_spec.rb +245 -280
  55. data/spec/services/subscriptions_service_spec.rb +423 -485
  56. data/spec/spec_helper.rb +46 -48
  57. metadata +22 -20
@@ -1,119 +1,82 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::RedirectFlow do
4
- describe "initialising" do
4
+ describe 'initialising' do
5
5
  let(:data) do
6
6
  {
7
-
8
-
9
- "created_at" => "created_at-input",
10
-
11
-
12
-
13
- "description" => "description-input",
14
-
15
-
16
-
17
- "id" => "id-input",
18
-
19
-
20
-
21
- "links" => {
22
-
23
- "creditor" => "creditor-input",
24
-
25
- "customer" => "customer-input",
26
-
27
- "customer_bank_account" => "customer_bank_account-input",
28
-
29
- "mandate" => "mandate-input",
30
-
7
+
8
+ 'created_at' => 'created_at-input',
9
+
10
+ 'description' => 'description-input',
11
+
12
+ 'id' => 'id-input',
13
+
14
+ 'links' => {
15
+
16
+ 'creditor' => 'creditor-input',
17
+
18
+ 'customer' => 'customer-input',
19
+
20
+ 'customer_bank_account' => 'customer_bank_account-input',
21
+
22
+ 'mandate' => 'mandate-input'
23
+
31
24
  },
32
-
33
-
34
-
35
- "redirect_url" => "redirect_url-input",
36
-
37
-
38
-
39
- "scheme" => "scheme-input",
40
-
41
-
42
-
43
- "session_token" => "session_token-input",
44
-
45
-
46
-
47
- "success_redirect_url" => "success_redirect_url-input",
48
-
49
-
25
+
26
+ 'redirect_url' => 'redirect_url-input',
27
+
28
+ 'scheme' => 'scheme-input',
29
+
30
+ 'session_token' => 'session_token-input',
31
+
32
+ 'success_redirect_url' => 'success_redirect_url-input'
33
+
50
34
  }
51
35
  end
52
36
 
53
- it "can be initialized from an unenveloped response" do
37
+ it 'can be initialized from an unenveloped response' do
54
38
  resource = described_class.new(data)
55
-
56
-
57
- expect(resource.created_at).to eq("created_at-input")
58
-
59
-
60
-
61
- expect(resource.description).to eq("description-input")
62
-
63
-
64
-
65
- expect(resource.id).to eq("id-input")
66
-
67
-
68
-
69
-
70
- expect(resource.links.creditor).to eq("creditor-input")
71
-
72
- expect(resource.links.customer).to eq("customer-input")
73
-
74
- expect(resource.links.customer_bank_account).to eq("customer_bank_account-input")
75
-
76
- expect(resource.links.mandate).to eq("mandate-input")
77
-
78
-
79
-
80
-
81
- expect(resource.redirect_url).to eq("redirect_url-input")
82
-
83
-
84
-
85
- expect(resource.scheme).to eq("scheme-input")
86
-
87
-
88
-
89
- expect(resource.session_token).to eq("session_token-input")
90
-
91
-
92
-
93
- expect(resource.success_redirect_url).to eq("success_redirect_url-input")
94
-
95
-
39
+
40
+ expect(resource.created_at).to eq('created_at-input')
41
+
42
+ expect(resource.description).to eq('description-input')
43
+
44
+ expect(resource.id).to eq('id-input')
45
+
46
+ expect(resource.links.creditor).to eq('creditor-input')
47
+
48
+ expect(resource.links.customer).to eq('customer-input')
49
+
50
+ expect(resource.links.customer_bank_account).to eq('customer_bank_account-input')
51
+
52
+ expect(resource.links.mandate).to eq('mandate-input')
53
+
54
+ expect(resource.redirect_url).to eq('redirect_url-input')
55
+
56
+ expect(resource.scheme).to eq('scheme-input')
57
+
58
+ expect(resource.session_token).to eq('session_token-input')
59
+
60
+ expect(resource.success_redirect_url).to eq('success_redirect_url-input')
96
61
  end
97
62
 
98
- it "can handle new attributes without erroring" do
99
- data["foo"] = "bar"
63
+ it 'can handle new attributes without erroring' do
64
+ data['foo'] = 'bar'
100
65
  expect { described_class.new(data) }.to_not raise_error
101
66
  end
102
67
 
103
-
104
- it "can handle new link attributes without erroring" do
105
- data["links"]["foo"] = "bar"
68
+ it 'can handle new link attributes without erroring' do
69
+ data['links']['foo'] = 'bar'
106
70
  expect { described_class.new(data) }.to_not raise_error
107
71
  end
108
72
 
109
- it "can handle a nil links value" do
110
- data["links"] = nil
73
+ it 'can handle a nil links value' do
74
+ data['links'] = nil
111
75
  expect { described_class.new(data).links }.to_not raise_error
112
76
  end
113
-
114
77
 
115
- describe "#to_h" do
116
- it "returns a hash representing the resource" do
78
+ describe '#to_h' do
79
+ it 'returns a hash representing the resource' do
117
80
  expect(described_class.new(data).to_h).to eq(data)
118
81
  end
119
82
  end
@@ -1,99 +1,66 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::Refund do
4
- describe "initialising" do
4
+ describe 'initialising' do
5
5
  let(:data) do
6
6
  {
7
-
8
-
9
- "amount" => "amount-input",
10
-
11
-
12
-
13
- "created_at" => "created_at-input",
14
-
15
-
16
-
17
- "currency" => "currency-input",
18
-
19
-
20
-
21
- "id" => "id-input",
22
-
23
-
24
-
25
- "links" => {
26
-
27
- "payment" => "payment-input",
28
-
7
+
8
+ 'amount' => 'amount-input',
9
+
10
+ 'created_at' => 'created_at-input',
11
+
12
+ 'currency' => 'currency-input',
13
+
14
+ 'id' => 'id-input',
15
+
16
+ 'links' => {
17
+
18
+ 'payment' => 'payment-input'
19
+
29
20
  },
30
-
31
-
32
-
33
- "metadata" => "metadata-input",
34
-
35
-
36
-
37
- "reference" => "reference-input",
38
-
39
-
21
+
22
+ 'metadata' => 'metadata-input',
23
+
24
+ 'reference' => 'reference-input'
25
+
40
26
  }
41
27
  end
42
28
 
43
- it "can be initialized from an unenveloped response" do
29
+ it 'can be initialized from an unenveloped response' do
44
30
  resource = described_class.new(data)
45
-
46
-
47
- expect(resource.amount).to eq("amount-input")
48
-
49
-
50
-
51
- expect(resource.created_at).to eq("created_at-input")
52
-
53
-
54
-
55
- expect(resource.currency).to eq("currency-input")
56
-
57
-
58
-
59
- expect(resource.id).to eq("id-input")
60
-
61
-
62
-
63
-
64
- expect(resource.links.payment).to eq("payment-input")
65
-
66
-
67
-
68
-
69
- expect(resource.metadata).to eq("metadata-input")
70
-
71
-
72
-
73
- expect(resource.reference).to eq("reference-input")
74
-
75
-
31
+
32
+ expect(resource.amount).to eq('amount-input')
33
+
34
+ expect(resource.created_at).to eq('created_at-input')
35
+
36
+ expect(resource.currency).to eq('currency-input')
37
+
38
+ expect(resource.id).to eq('id-input')
39
+
40
+ expect(resource.links.payment).to eq('payment-input')
41
+
42
+ expect(resource.metadata).to eq('metadata-input')
43
+
44
+ expect(resource.reference).to eq('reference-input')
76
45
  end
77
46
 
78
- it "can handle new attributes without erroring" do
79
- data["foo"] = "bar"
47
+ it 'can handle new attributes without erroring' do
48
+ data['foo'] = 'bar'
80
49
  expect { described_class.new(data) }.to_not raise_error
81
50
  end
82
51
 
83
-
84
- it "can handle new link attributes without erroring" do
85
- data["links"]["foo"] = "bar"
52
+ it 'can handle new link attributes without erroring' do
53
+ data['links']['foo'] = 'bar'
86
54
  expect { described_class.new(data) }.to_not raise_error
87
55
  end
88
56
 
89
- it "can handle a nil links value" do
90
- data["links"] = nil
57
+ it 'can handle a nil links value' do
58
+ data['links'] = nil
91
59
  expect { described_class.new(data).links }.to_not raise_error
92
60
  end
93
-
94
61
 
95
- describe "#to_h" do
96
- it "returns a hash representing the resource" do
62
+ describe '#to_h' do
63
+ it 'returns a hash representing the resource' do
97
64
  expect(described_class.new(data).to_h).to eq(data)
98
65
  end
99
66
  end
@@ -1,179 +1,106 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::Subscription do
4
- describe "initialising" do
4
+ describe 'initialising' do
5
5
  let(:data) do
6
6
  {
7
-
8
-
9
- "amount" => "amount-input",
10
-
11
-
12
-
13
- "count" => "count-input",
14
-
15
-
16
-
17
- "created_at" => "created_at-input",
18
-
19
-
20
-
21
- "currency" => "currency-input",
22
-
23
-
24
-
25
- "day_of_month" => "day_of_month-input",
26
-
27
-
28
-
29
- "end_date" => "end_date-input",
30
-
31
-
32
-
33
- "id" => "id-input",
34
-
35
-
36
-
37
- "interval" => "interval-input",
38
-
39
-
40
-
41
- "interval_unit" => "interval_unit-input",
42
-
43
-
44
-
45
- "links" => {
46
-
47
- "mandate" => "mandate-input",
48
-
7
+
8
+ 'amount' => 'amount-input',
9
+
10
+ 'count' => 'count-input',
11
+
12
+ 'created_at' => 'created_at-input',
13
+
14
+ 'currency' => 'currency-input',
15
+
16
+ 'day_of_month' => 'day_of_month-input',
17
+
18
+ 'end_date' => 'end_date-input',
19
+
20
+ 'id' => 'id-input',
21
+
22
+ 'interval' => 'interval-input',
23
+
24
+ 'interval_unit' => 'interval_unit-input',
25
+
26
+ 'links' => {
27
+
28
+ 'mandate' => 'mandate-input'
29
+
49
30
  },
50
-
51
-
52
-
53
- "metadata" => "metadata-input",
54
-
55
-
56
-
57
- "month" => "month-input",
58
-
59
-
60
-
61
- "name" => "name-input",
62
-
63
-
64
-
65
- "payment_reference" => "payment_reference-input",
66
-
67
-
68
-
69
- "start_date" => "start_date-input",
70
-
71
-
72
-
73
- "status" => "status-input",
74
-
75
-
76
-
77
- "upcoming_payments" => "upcoming_payments-input",
78
-
79
-
31
+
32
+ 'metadata' => 'metadata-input',
33
+
34
+ 'month' => 'month-input',
35
+
36
+ 'name' => 'name-input',
37
+
38
+ 'payment_reference' => 'payment_reference-input',
39
+
40
+ 'start_date' => 'start_date-input',
41
+
42
+ 'status' => 'status-input',
43
+
44
+ 'upcoming_payments' => 'upcoming_payments-input'
45
+
80
46
  }
81
47
  end
82
48
 
83
- it "can be initialized from an unenveloped response" do
49
+ it 'can be initialized from an unenveloped response' do
84
50
  resource = described_class.new(data)
85
-
86
-
87
- expect(resource.amount).to eq("amount-input")
88
-
89
-
90
-
91
- expect(resource.count).to eq("count-input")
92
-
93
-
94
-
95
- expect(resource.created_at).to eq("created_at-input")
96
-
97
-
98
-
99
- expect(resource.currency).to eq("currency-input")
100
-
101
-
102
-
103
- expect(resource.day_of_month).to eq("day_of_month-input")
104
-
105
-
106
-
107
- expect(resource.end_date).to eq("end_date-input")
108
-
109
-
110
-
111
- expect(resource.id).to eq("id-input")
112
-
113
-
114
-
115
- expect(resource.interval).to eq("interval-input")
116
-
117
-
118
-
119
- expect(resource.interval_unit).to eq("interval_unit-input")
120
-
121
-
122
-
123
-
124
- expect(resource.links.mandate).to eq("mandate-input")
125
-
126
-
127
-
128
-
129
- expect(resource.metadata).to eq("metadata-input")
130
-
131
-
132
-
133
- expect(resource.month).to eq("month-input")
134
-
135
-
136
-
137
- expect(resource.name).to eq("name-input")
138
-
139
-
140
-
141
- expect(resource.payment_reference).to eq("payment_reference-input")
142
-
143
-
144
-
145
- expect(resource.start_date).to eq("start_date-input")
146
-
147
-
148
-
149
- expect(resource.status).to eq("status-input")
150
-
151
-
152
-
153
- expect(resource.upcoming_payments).to eq("upcoming_payments-input")
154
-
155
-
51
+
52
+ expect(resource.amount).to eq('amount-input')
53
+
54
+ expect(resource.count).to eq('count-input')
55
+
56
+ expect(resource.created_at).to eq('created_at-input')
57
+
58
+ expect(resource.currency).to eq('currency-input')
59
+
60
+ expect(resource.day_of_month).to eq('day_of_month-input')
61
+
62
+ expect(resource.end_date).to eq('end_date-input')
63
+
64
+ expect(resource.id).to eq('id-input')
65
+
66
+ expect(resource.interval).to eq('interval-input')
67
+
68
+ expect(resource.interval_unit).to eq('interval_unit-input')
69
+
70
+ expect(resource.links.mandate).to eq('mandate-input')
71
+
72
+ expect(resource.metadata).to eq('metadata-input')
73
+
74
+ expect(resource.month).to eq('month-input')
75
+
76
+ expect(resource.name).to eq('name-input')
77
+
78
+ expect(resource.payment_reference).to eq('payment_reference-input')
79
+
80
+ expect(resource.start_date).to eq('start_date-input')
81
+
82
+ expect(resource.status).to eq('status-input')
83
+
84
+ expect(resource.upcoming_payments).to eq('upcoming_payments-input')
156
85
  end
157
86
 
158
- it "can handle new attributes without erroring" do
159
- data["foo"] = "bar"
87
+ it 'can handle new attributes without erroring' do
88
+ data['foo'] = 'bar'
160
89
  expect { described_class.new(data) }.to_not raise_error
161
90
  end
162
91
 
163
-
164
- it "can handle new link attributes without erroring" do
165
- data["links"]["foo"] = "bar"
92
+ it 'can handle new link attributes without erroring' do
93
+ data['links']['foo'] = 'bar'
166
94
  expect { described_class.new(data) }.to_not raise_error
167
95
  end
168
96
 
169
- it "can handle a nil links value" do
170
- data["links"] = nil
97
+ it 'can handle a nil links value' do
98
+ data['links'] = nil
171
99
  expect { described_class.new(data).links }.to_not raise_error
172
100
  end
173
-
174
101
 
175
- describe "#to_h" do
176
- it "returns a hash representing the resource" do
102
+ describe '#to_h' do
103
+ it 'returns a hash representing the resource' do
177
104
  expect(described_class.new(data).to_h).to eq(data)
178
105
  end
179
106
  end