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,123 +1,78 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::CustomerBankAccount do
4
- describe "initialising" do
4
+ describe 'initialising' do
5
5
  let(:data) do
6
6
  {
7
-
8
-
9
- "account_holder_name" => "account_holder_name-input",
10
-
11
-
12
-
13
- "account_number_ending" => "account_number_ending-input",
14
-
15
-
16
-
17
- "bank_name" => "bank_name-input",
18
-
19
-
20
-
21
- "country_code" => "country_code-input",
22
-
23
-
24
-
25
- "created_at" => "created_at-input",
26
-
27
-
28
-
29
- "currency" => "currency-input",
30
-
31
-
32
-
33
- "enabled" => "enabled-input",
34
-
35
-
36
-
37
- "id" => "id-input",
38
-
39
-
40
-
41
- "links" => {
42
-
43
- "customer" => "customer-input",
44
-
7
+
8
+ 'account_holder_name' => 'account_holder_name-input',
9
+
10
+ 'account_number_ending' => 'account_number_ending-input',
11
+
12
+ 'bank_name' => 'bank_name-input',
13
+
14
+ 'country_code' => 'country_code-input',
15
+
16
+ 'created_at' => 'created_at-input',
17
+
18
+ 'currency' => 'currency-input',
19
+
20
+ 'enabled' => 'enabled-input',
21
+
22
+ 'id' => 'id-input',
23
+
24
+ 'links' => {
25
+
26
+ 'customer' => 'customer-input'
27
+
45
28
  },
46
-
47
-
48
-
49
- "metadata" => "metadata-input",
50
-
51
-
29
+
30
+ 'metadata' => 'metadata-input'
31
+
52
32
  }
53
33
  end
54
34
 
55
- it "can be initialized from an unenveloped response" do
35
+ it 'can be initialized from an unenveloped response' do
56
36
  resource = described_class.new(data)
57
-
58
-
59
- expect(resource.account_holder_name).to eq("account_holder_name-input")
60
-
61
-
62
-
63
- expect(resource.account_number_ending).to eq("account_number_ending-input")
64
-
65
-
66
-
67
- expect(resource.bank_name).to eq("bank_name-input")
68
-
69
-
70
-
71
- expect(resource.country_code).to eq("country_code-input")
72
-
73
-
74
-
75
- expect(resource.created_at).to eq("created_at-input")
76
-
77
-
78
-
79
- expect(resource.currency).to eq("currency-input")
80
-
81
-
82
-
83
- expect(resource.enabled).to eq("enabled-input")
84
-
85
-
86
-
87
- expect(resource.id).to eq("id-input")
88
-
89
-
90
-
91
-
92
- expect(resource.links.customer).to eq("customer-input")
93
-
94
-
95
-
96
-
97
- expect(resource.metadata).to eq("metadata-input")
98
-
99
-
37
+
38
+ expect(resource.account_holder_name).to eq('account_holder_name-input')
39
+
40
+ expect(resource.account_number_ending).to eq('account_number_ending-input')
41
+
42
+ expect(resource.bank_name).to eq('bank_name-input')
43
+
44
+ expect(resource.country_code).to eq('country_code-input')
45
+
46
+ expect(resource.created_at).to eq('created_at-input')
47
+
48
+ expect(resource.currency).to eq('currency-input')
49
+
50
+ expect(resource.enabled).to eq('enabled-input')
51
+
52
+ expect(resource.id).to eq('id-input')
53
+
54
+ expect(resource.links.customer).to eq('customer-input')
55
+
56
+ expect(resource.metadata).to eq('metadata-input')
100
57
  end
101
58
 
102
- it "can handle new attributes without erroring" do
103
- data["foo"] = "bar"
59
+ it 'can handle new attributes without erroring' do
60
+ data['foo'] = 'bar'
104
61
  expect { described_class.new(data) }.to_not raise_error
105
62
  end
106
63
 
107
-
108
- it "can handle new link attributes without erroring" do
109
- data["links"]["foo"] = "bar"
64
+ it 'can handle new link attributes without erroring' do
65
+ data['links']['foo'] = 'bar'
110
66
  expect { described_class.new(data) }.to_not raise_error
111
67
  end
112
68
 
113
- it "can handle a nil links value" do
114
- data["links"] = nil
69
+ it 'can handle a nil links value' do
70
+ data['links'] = nil
115
71
  expect { described_class.new(data).links }.to_not raise_error
116
72
  end
117
-
118
73
 
119
- describe "#to_h" do
120
- it "returns a hash representing the resource" do
74
+ describe '#to_h' do
75
+ it 'returns a hash representing the resource' do
121
76
  expect(described_class.new(data).to_h).to eq(data)
122
77
  end
123
78
  end
@@ -1,155 +1,88 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::Customer do
4
- describe "initialising" do
4
+ describe 'initialising' do
5
5
  let(:data) do
6
6
  {
7
-
8
-
9
- "address_line1" => "address_line1-input",
10
-
11
-
12
-
13
- "address_line2" => "address_line2-input",
14
-
15
-
16
-
17
- "address_line3" => "address_line3-input",
18
-
19
-
20
-
21
- "city" => "city-input",
22
-
23
-
24
-
25
- "company_name" => "company_name-input",
26
-
27
-
28
-
29
- "country_code" => "country_code-input",
30
-
31
-
32
-
33
- "created_at" => "created_at-input",
34
-
35
-
36
-
37
- "email" => "email-input",
38
-
39
-
40
-
41
- "family_name" => "family_name-input",
42
-
43
-
44
-
45
- "given_name" => "given_name-input",
46
-
47
-
48
-
49
- "id" => "id-input",
50
-
51
-
52
-
53
- "language" => "language-input",
54
-
55
-
56
-
57
- "metadata" => "metadata-input",
58
-
59
-
60
-
61
- "postal_code" => "postal_code-input",
62
-
63
-
64
-
65
- "region" => "region-input",
66
-
67
-
68
-
69
- "swedish_identity_number" => "swedish_identity_number-input",
70
-
71
-
7
+
8
+ 'address_line1' => 'address_line1-input',
9
+
10
+ 'address_line2' => 'address_line2-input',
11
+
12
+ 'address_line3' => 'address_line3-input',
13
+
14
+ 'city' => 'city-input',
15
+
16
+ 'company_name' => 'company_name-input',
17
+
18
+ 'country_code' => 'country_code-input',
19
+
20
+ 'created_at' => 'created_at-input',
21
+
22
+ 'email' => 'email-input',
23
+
24
+ 'family_name' => 'family_name-input',
25
+
26
+ 'given_name' => 'given_name-input',
27
+
28
+ 'id' => 'id-input',
29
+
30
+ 'language' => 'language-input',
31
+
32
+ 'metadata' => 'metadata-input',
33
+
34
+ 'postal_code' => 'postal_code-input',
35
+
36
+ 'region' => 'region-input',
37
+
38
+ 'swedish_identity_number' => 'swedish_identity_number-input'
39
+
72
40
  }
73
41
  end
74
42
 
75
- it "can be initialized from an unenveloped response" do
43
+ it 'can be initialized from an unenveloped response' do
76
44
  resource = described_class.new(data)
77
-
78
-
79
- expect(resource.address_line1).to eq("address_line1-input")
80
-
81
-
82
-
83
- expect(resource.address_line2).to eq("address_line2-input")
84
-
85
-
86
-
87
- expect(resource.address_line3).to eq("address_line3-input")
88
-
89
-
90
-
91
- expect(resource.city).to eq("city-input")
92
-
93
-
94
-
95
- expect(resource.company_name).to eq("company_name-input")
96
-
97
-
98
-
99
- expect(resource.country_code).to eq("country_code-input")
100
-
101
-
102
-
103
- expect(resource.created_at).to eq("created_at-input")
104
-
105
-
106
-
107
- expect(resource.email).to eq("email-input")
108
-
109
-
110
-
111
- expect(resource.family_name).to eq("family_name-input")
112
-
113
-
114
-
115
- expect(resource.given_name).to eq("given_name-input")
116
-
117
-
118
-
119
- expect(resource.id).to eq("id-input")
120
-
121
-
122
-
123
- expect(resource.language).to eq("language-input")
124
-
125
-
126
-
127
- expect(resource.metadata).to eq("metadata-input")
128
-
129
-
130
-
131
- expect(resource.postal_code).to eq("postal_code-input")
132
-
133
-
134
-
135
- expect(resource.region).to eq("region-input")
136
-
137
-
138
-
139
- expect(resource.swedish_identity_number).to eq("swedish_identity_number-input")
140
-
141
-
45
+
46
+ expect(resource.address_line1).to eq('address_line1-input')
47
+
48
+ expect(resource.address_line2).to eq('address_line2-input')
49
+
50
+ expect(resource.address_line3).to eq('address_line3-input')
51
+
52
+ expect(resource.city).to eq('city-input')
53
+
54
+ expect(resource.company_name).to eq('company_name-input')
55
+
56
+ expect(resource.country_code).to eq('country_code-input')
57
+
58
+ expect(resource.created_at).to eq('created_at-input')
59
+
60
+ expect(resource.email).to eq('email-input')
61
+
62
+ expect(resource.family_name).to eq('family_name-input')
63
+
64
+ expect(resource.given_name).to eq('given_name-input')
65
+
66
+ expect(resource.id).to eq('id-input')
67
+
68
+ expect(resource.language).to eq('language-input')
69
+
70
+ expect(resource.metadata).to eq('metadata-input')
71
+
72
+ expect(resource.postal_code).to eq('postal_code-input')
73
+
74
+ expect(resource.region).to eq('region-input')
75
+
76
+ expect(resource.swedish_identity_number).to eq('swedish_identity_number-input')
142
77
  end
143
78
 
144
- it "can handle new attributes without erroring" do
145
- data["foo"] = "bar"
79
+ it 'can handle new attributes without erroring' do
80
+ data['foo'] = 'bar'
146
81
  expect { described_class.new(data) }.to_not raise_error
147
82
  end
148
83
 
149
-
150
-
151
- describe "#to_h" do
152
- it "returns a hash representing the resource" do
84
+ describe '#to_h' do
85
+ it 'returns a hash representing the resource' do
153
86
  expect(described_class.new(data).to_h).to eq(data)
154
87
  end
155
88
  end
@@ -1,131 +1,98 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::Event do
4
- describe "initialising" do
4
+ describe 'initialising' do
5
5
  let(:data) do
6
6
  {
7
-
8
-
9
- "action" => "action-input",
10
-
11
-
12
-
13
- "created_at" => "created_at-input",
14
-
15
-
16
-
17
- "details" => "details-input",
18
-
19
-
20
-
21
- "id" => "id-input",
22
-
23
-
24
-
25
- "links" => {
26
-
27
- "mandate" => "mandate-input",
28
-
29
- "new_customer_bank_account" => "new_customer_bank_account-input",
30
-
31
- "organisation" => "organisation-input",
32
-
33
- "parent_event" => "parent_event-input",
34
-
35
- "payment" => "payment-input",
36
-
37
- "payout" => "payout-input",
38
-
39
- "previous_customer_bank_account" => "previous_customer_bank_account-input",
40
-
41
- "refund" => "refund-input",
42
-
43
- "subscription" => "subscription-input",
44
-
7
+
8
+ 'action' => 'action-input',
9
+
10
+ 'created_at' => 'created_at-input',
11
+
12
+ 'details' => 'details-input',
13
+
14
+ 'id' => 'id-input',
15
+
16
+ 'links' => {
17
+
18
+ 'mandate' => 'mandate-input',
19
+
20
+ 'new_customer_bank_account' => 'new_customer_bank_account-input',
21
+
22
+ 'organisation' => 'organisation-input',
23
+
24
+ 'parent_event' => 'parent_event-input',
25
+
26
+ 'payment' => 'payment-input',
27
+
28
+ 'payout' => 'payout-input',
29
+
30
+ 'previous_customer_bank_account' => 'previous_customer_bank_account-input',
31
+
32
+ 'refund' => 'refund-input',
33
+
34
+ 'subscription' => 'subscription-input'
35
+
45
36
  },
46
-
47
-
48
-
49
- "metadata" => "metadata-input",
50
-
51
-
52
-
53
- "resource_type" => "resource_type-input",
54
-
55
-
37
+
38
+ 'metadata' => 'metadata-input',
39
+
40
+ 'resource_type' => 'resource_type-input'
41
+
56
42
  }
57
43
  end
58
44
 
59
- it "can be initialized from an unenveloped response" do
45
+ it 'can be initialized from an unenveloped response' do
60
46
  resource = described_class.new(data)
61
-
62
-
63
- expect(resource.action).to eq("action-input")
64
-
65
-
66
-
67
- expect(resource.created_at).to eq("created_at-input")
68
-
69
-
70
-
71
- expect(resource.details).to eq("details-input")
72
-
73
-
74
-
75
- expect(resource.id).to eq("id-input")
76
-
77
-
78
-
79
-
80
- expect(resource.links.mandate).to eq("mandate-input")
81
-
82
- expect(resource.links.new_customer_bank_account).to eq("new_customer_bank_account-input")
83
-
84
- expect(resource.links.organisation).to eq("organisation-input")
85
-
86
- expect(resource.links.parent_event).to eq("parent_event-input")
87
-
88
- expect(resource.links.payment).to eq("payment-input")
89
-
90
- expect(resource.links.payout).to eq("payout-input")
91
-
92
- expect(resource.links.previous_customer_bank_account).to eq("previous_customer_bank_account-input")
93
-
94
- expect(resource.links.refund).to eq("refund-input")
95
-
96
- expect(resource.links.subscription).to eq("subscription-input")
97
-
98
-
99
-
100
-
101
- expect(resource.metadata).to eq("metadata-input")
102
-
103
-
104
-
105
- expect(resource.resource_type).to eq("resource_type-input")
106
-
107
-
47
+
48
+ expect(resource.action).to eq('action-input')
49
+
50
+ expect(resource.created_at).to eq('created_at-input')
51
+
52
+ expect(resource.details).to eq('details-input')
53
+
54
+ expect(resource.id).to eq('id-input')
55
+
56
+ expect(resource.links.mandate).to eq('mandate-input')
57
+
58
+ expect(resource.links.new_customer_bank_account).to eq('new_customer_bank_account-input')
59
+
60
+ expect(resource.links.organisation).to eq('organisation-input')
61
+
62
+ expect(resource.links.parent_event).to eq('parent_event-input')
63
+
64
+ expect(resource.links.payment).to eq('payment-input')
65
+
66
+ expect(resource.links.payout).to eq('payout-input')
67
+
68
+ expect(resource.links.previous_customer_bank_account).to eq('previous_customer_bank_account-input')
69
+
70
+ expect(resource.links.refund).to eq('refund-input')
71
+
72
+ expect(resource.links.subscription).to eq('subscription-input')
73
+
74
+ expect(resource.metadata).to eq('metadata-input')
75
+
76
+ expect(resource.resource_type).to eq('resource_type-input')
108
77
  end
109
78
 
110
- it "can handle new attributes without erroring" do
111
- data["foo"] = "bar"
79
+ it 'can handle new attributes without erroring' do
80
+ data['foo'] = 'bar'
112
81
  expect { described_class.new(data) }.to_not raise_error
113
82
  end
114
83
 
115
-
116
- it "can handle new link attributes without erroring" do
117
- data["links"]["foo"] = "bar"
84
+ it 'can handle new link attributes without erroring' do
85
+ data['links']['foo'] = 'bar'
118
86
  expect { described_class.new(data) }.to_not raise_error
119
87
  end
120
88
 
121
- it "can handle a nil links value" do
122
- data["links"] = nil
89
+ it 'can handle a nil links value' do
90
+ data['links'] = nil
123
91
  expect { described_class.new(data).links }.to_not raise_error
124
92
  end
125
-
126
93
 
127
- describe "#to_h" do
128
- it "returns a hash representing the resource" do
94
+ describe '#to_h' do
95
+ it 'returns a hash representing the resource' do
129
96
  expect(described_class.new(data).to_h).to eq(data)
130
97
  end
131
98
  end