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,43 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::MandatePdf do
4
- describe "initialising" do
4
+ describe 'initialising' do
5
5
  let(:data) do
6
6
  {
7
-
8
-
9
- "expires_at" => "expires_at-input",
10
-
11
-
12
-
13
- "url" => "url-input",
14
-
15
-
7
+
8
+ 'expires_at' => 'expires_at-input',
9
+
10
+ 'url' => 'url-input'
11
+
16
12
  }
17
13
  end
18
14
 
19
- it "can be initialized from an unenveloped response" do
15
+ it 'can be initialized from an unenveloped response' do
20
16
  resource = described_class.new(data)
21
-
22
-
23
- expect(resource.expires_at).to eq("expires_at-input")
24
-
25
-
26
-
27
- expect(resource.url).to eq("url-input")
28
-
29
-
17
+
18
+ expect(resource.expires_at).to eq('expires_at-input')
19
+
20
+ expect(resource.url).to eq('url-input')
30
21
  end
31
22
 
32
- it "can handle new attributes without erroring" do
33
- data["foo"] = "bar"
23
+ it 'can handle new attributes without erroring' do
24
+ data['foo'] = 'bar'
34
25
  expect { described_class.new(data) }.to_not raise_error
35
26
  end
36
27
 
37
-
38
-
39
- describe "#to_h" do
40
- it "returns a hash representing the resource" do
28
+ describe '#to_h' do
29
+ it 'returns a hash representing the resource' do
41
30
  expect(described_class.new(data).to_h).to eq(data)
42
31
  end
43
32
  end
@@ -1,111 +1,78 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::Mandate 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
- "id" => "id-input",
14
-
15
-
16
-
17
- "links" => {
18
-
19
- "creditor" => "creditor-input",
20
-
21
- "customer_bank_account" => "customer_bank_account-input",
22
-
7
+
8
+ 'created_at' => 'created_at-input',
9
+
10
+ 'id' => 'id-input',
11
+
12
+ 'links' => {
13
+
14
+ 'creditor' => 'creditor-input',
15
+
16
+ 'customer_bank_account' => 'customer_bank_account-input'
17
+
23
18
  },
24
-
25
-
26
-
27
- "metadata" => "metadata-input",
28
-
29
-
30
-
31
- "next_possible_charge_date" => "next_possible_charge_date-input",
32
-
33
-
34
-
35
- "reference" => "reference-input",
36
-
37
-
38
-
39
- "scheme" => "scheme-input",
40
-
41
-
42
-
43
- "status" => "status-input",
44
-
45
-
19
+
20
+ 'metadata' => 'metadata-input',
21
+
22
+ 'next_possible_charge_date' => 'next_possible_charge_date-input',
23
+
24
+ 'payments_require_approval' => 'payments_require_approval-input',
25
+
26
+ 'reference' => 'reference-input',
27
+
28
+ 'scheme' => 'scheme-input',
29
+
30
+ 'status' => 'status-input'
31
+
46
32
  }
47
33
  end
48
34
 
49
- it "can be initialized from an unenveloped response" do
35
+ it 'can be initialized from an unenveloped response' do
50
36
  resource = described_class.new(data)
51
-
52
-
53
- expect(resource.created_at).to eq("created_at-input")
54
-
55
-
56
-
57
- expect(resource.id).to eq("id-input")
58
-
59
-
60
-
61
-
62
- expect(resource.links.creditor).to eq("creditor-input")
63
-
64
- expect(resource.links.customer_bank_account).to eq("customer_bank_account-input")
65
-
66
-
67
-
68
-
69
- expect(resource.metadata).to eq("metadata-input")
70
-
71
-
72
-
73
- expect(resource.next_possible_charge_date).to eq("next_possible_charge_date-input")
74
-
75
-
76
-
77
- expect(resource.reference).to eq("reference-input")
78
-
79
-
80
-
81
- expect(resource.scheme).to eq("scheme-input")
82
-
83
-
84
-
85
- expect(resource.status).to eq("status-input")
86
-
87
-
37
+
38
+ expect(resource.created_at).to eq('created_at-input')
39
+
40
+ expect(resource.id).to eq('id-input')
41
+
42
+ expect(resource.links.creditor).to eq('creditor-input')
43
+
44
+ expect(resource.links.customer_bank_account).to eq('customer_bank_account-input')
45
+
46
+ expect(resource.metadata).to eq('metadata-input')
47
+
48
+ expect(resource.next_possible_charge_date).to eq('next_possible_charge_date-input')
49
+
50
+ expect(resource.payments_require_approval).to eq('payments_require_approval-input')
51
+
52
+ expect(resource.reference).to eq('reference-input')
53
+
54
+ expect(resource.scheme).to eq('scheme-input')
55
+
56
+ expect(resource.status).to eq('status-input')
88
57
  end
89
58
 
90
- it "can handle new attributes without erroring" do
91
- data["foo"] = "bar"
59
+ it 'can handle new attributes without erroring' do
60
+ data['foo'] = 'bar'
92
61
  expect { described_class.new(data) }.to_not raise_error
93
62
  end
94
63
 
95
-
96
- it "can handle new link attributes without erroring" do
97
- data["links"]["foo"] = "bar"
64
+ it 'can handle new link attributes without erroring' do
65
+ data['links']['foo'] = 'bar'
98
66
  expect { described_class.new(data) }.to_not raise_error
99
67
  end
100
68
 
101
- it "can handle a nil links value" do
102
- data["links"] = nil
69
+ it 'can handle a nil links value' do
70
+ data['links'] = nil
103
71
  expect { described_class.new(data).links }.to_not raise_error
104
72
  end
105
-
106
73
 
107
- describe "#to_h" do
108
- it "returns a hash representing the resource" do
74
+ describe '#to_h' do
75
+ it 'returns a hash representing the resource' do
109
76
  expect(described_class.new(data).to_h).to eq(data)
110
77
  end
111
78
  end
@@ -1,143 +1,94 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::Payment 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
- "amount_refunded" => "amount_refunded-input",
14
-
15
-
16
-
17
- "charge_date" => "charge_date-input",
18
-
19
-
20
-
21
- "created_at" => "created_at-input",
22
-
23
-
24
-
25
- "currency" => "currency-input",
26
-
27
-
28
-
29
- "description" => "description-input",
30
-
31
-
32
-
33
- "id" => "id-input",
34
-
35
-
36
-
37
- "links" => {
38
-
39
- "creditor" => "creditor-input",
40
-
41
- "mandate" => "mandate-input",
42
-
43
- "payout" => "payout-input",
44
-
45
- "subscription" => "subscription-input",
46
-
7
+
8
+ 'amount' => 'amount-input',
9
+
10
+ 'amount_refunded' => 'amount_refunded-input',
11
+
12
+ 'charge_date' => 'charge_date-input',
13
+
14
+ 'created_at' => 'created_at-input',
15
+
16
+ 'currency' => 'currency-input',
17
+
18
+ 'description' => 'description-input',
19
+
20
+ 'id' => 'id-input',
21
+
22
+ 'links' => {
23
+
24
+ 'creditor' => 'creditor-input',
25
+
26
+ 'mandate' => 'mandate-input',
27
+
28
+ 'payout' => 'payout-input',
29
+
30
+ 'subscription' => 'subscription-input'
31
+
47
32
  },
48
-
49
-
50
-
51
- "metadata" => "metadata-input",
52
-
53
-
54
-
55
- "reference" => "reference-input",
56
-
57
-
58
-
59
- "status" => "status-input",
60
-
61
-
33
+
34
+ 'metadata' => 'metadata-input',
35
+
36
+ 'reference' => 'reference-input',
37
+
38
+ 'status' => 'status-input'
39
+
62
40
  }
63
41
  end
64
42
 
65
- it "can be initialized from an unenveloped response" do
43
+ it 'can be initialized from an unenveloped response' do
66
44
  resource = described_class.new(data)
67
-
68
-
69
- expect(resource.amount).to eq("amount-input")
70
-
71
-
72
-
73
- expect(resource.amount_refunded).to eq("amount_refunded-input")
74
-
75
-
76
-
77
- expect(resource.charge_date).to eq("charge_date-input")
78
-
79
-
80
-
81
- expect(resource.created_at).to eq("created_at-input")
82
-
83
-
84
-
85
- expect(resource.currency).to eq("currency-input")
86
-
87
-
88
-
89
- expect(resource.description).to eq("description-input")
90
-
91
-
92
-
93
- expect(resource.id).to eq("id-input")
94
-
95
-
96
-
97
-
98
- expect(resource.links.creditor).to eq("creditor-input")
99
-
100
- expect(resource.links.mandate).to eq("mandate-input")
101
-
102
- expect(resource.links.payout).to eq("payout-input")
103
-
104
- expect(resource.links.subscription).to eq("subscription-input")
105
-
106
-
107
-
108
-
109
- expect(resource.metadata).to eq("metadata-input")
110
-
111
-
112
-
113
- expect(resource.reference).to eq("reference-input")
114
-
115
-
116
-
117
- expect(resource.status).to eq("status-input")
118
-
119
-
45
+
46
+ expect(resource.amount).to eq('amount-input')
47
+
48
+ expect(resource.amount_refunded).to eq('amount_refunded-input')
49
+
50
+ expect(resource.charge_date).to eq('charge_date-input')
51
+
52
+ expect(resource.created_at).to eq('created_at-input')
53
+
54
+ expect(resource.currency).to eq('currency-input')
55
+
56
+ expect(resource.description).to eq('description-input')
57
+
58
+ expect(resource.id).to eq('id-input')
59
+
60
+ expect(resource.links.creditor).to eq('creditor-input')
61
+
62
+ expect(resource.links.mandate).to eq('mandate-input')
63
+
64
+ expect(resource.links.payout).to eq('payout-input')
65
+
66
+ expect(resource.links.subscription).to eq('subscription-input')
67
+
68
+ expect(resource.metadata).to eq('metadata-input')
69
+
70
+ expect(resource.reference).to eq('reference-input')
71
+
72
+ expect(resource.status).to eq('status-input')
120
73
  end
121
74
 
122
- it "can handle new attributes without erroring" do
123
- data["foo"] = "bar"
75
+ it 'can handle new attributes without erroring' do
76
+ data['foo'] = 'bar'
124
77
  expect { described_class.new(data) }.to_not raise_error
125
78
  end
126
79
 
127
-
128
- it "can handle new link attributes without erroring" do
129
- data["links"]["foo"] = "bar"
80
+ it 'can handle new link attributes without erroring' do
81
+ data['links']['foo'] = 'bar'
130
82
  expect { described_class.new(data) }.to_not raise_error
131
83
  end
132
84
 
133
- it "can handle a nil links value" do
134
- data["links"] = nil
85
+ it 'can handle a nil links value' do
86
+ data['links'] = nil
135
87
  expect { described_class.new(data).links }.to_not raise_error
136
88
  end
137
-
138
89
 
139
- describe "#to_h" do
140
- it "returns a hash representing the resource" do
90
+ describe '#to_h' do
91
+ it 'returns a hash representing the resource' do
141
92
  expect(described_class.new(data).to_h).to eq(data)
142
93
  end
143
94
  end
@@ -1,103 +1,74 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GoCardlessPro::Resources::Payout 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
- "creditor" => "creditor-input",
28
-
29
- "creditor_bank_account" => "creditor_bank_account-input",
30
-
7
+
8
+ 'amount' => 'amount-input',
9
+
10
+ 'arrival_date' => 'arrival_date-input',
11
+
12
+ 'created_at' => 'created_at-input',
13
+
14
+ 'currency' => 'currency-input',
15
+
16
+ 'id' => 'id-input',
17
+
18
+ 'links' => {
19
+
20
+ 'creditor' => 'creditor-input',
21
+
22
+ 'creditor_bank_account' => 'creditor_bank_account-input'
23
+
31
24
  },
32
-
33
-
34
-
35
- "reference" => "reference-input",
36
-
37
-
38
-
39
- "status" => "status-input",
40
-
41
-
25
+
26
+ 'reference' => 'reference-input',
27
+
28
+ 'status' => 'status-input'
29
+
42
30
  }
43
31
  end
44
32
 
45
- it "can be initialized from an unenveloped response" do
33
+ it 'can be initialized from an unenveloped response' do
46
34
  resource = described_class.new(data)
47
-
48
-
49
- expect(resource.amount).to eq("amount-input")
50
-
51
-
52
-
53
- expect(resource.created_at).to eq("created_at-input")
54
-
55
-
56
-
57
- expect(resource.currency).to eq("currency-input")
58
-
59
-
60
-
61
- expect(resource.id).to eq("id-input")
62
-
63
-
64
-
65
-
66
- expect(resource.links.creditor).to eq("creditor-input")
67
-
68
- expect(resource.links.creditor_bank_account).to eq("creditor_bank_account-input")
69
-
70
-
71
-
72
-
73
- expect(resource.reference).to eq("reference-input")
74
-
75
-
76
-
77
- expect(resource.status).to eq("status-input")
78
-
79
-
35
+
36
+ expect(resource.amount).to eq('amount-input')
37
+
38
+ expect(resource.arrival_date).to eq('arrival_date-input')
39
+
40
+ expect(resource.created_at).to eq('created_at-input')
41
+
42
+ expect(resource.currency).to eq('currency-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.creditor_bank_account).to eq('creditor_bank_account-input')
49
+
50
+ expect(resource.reference).to eq('reference-input')
51
+
52
+ expect(resource.status).to eq('status-input')
80
53
  end
81
54
 
82
- it "can handle new attributes without erroring" do
83
- data["foo"] = "bar"
55
+ it 'can handle new attributes without erroring' do
56
+ data['foo'] = 'bar'
84
57
  expect { described_class.new(data) }.to_not raise_error
85
58
  end
86
59
 
87
-
88
- it "can handle new link attributes without erroring" do
89
- data["links"]["foo"] = "bar"
60
+ it 'can handle new link attributes without erroring' do
61
+ data['links']['foo'] = 'bar'
90
62
  expect { described_class.new(data) }.to_not raise_error
91
63
  end
92
64
 
93
- it "can handle a nil links value" do
94
- data["links"] = nil
65
+ it 'can handle a nil links value' do
66
+ data['links'] = nil
95
67
  expect { described_class.new(data).links }.to_not raise_error
96
68
  end
97
-
98
69
 
99
- describe "#to_h" do
100
- it "returns a hash representing the resource" do
70
+ describe '#to_h' do
71
+ it 'returns a hash representing the resource' do
101
72
  expect(described_class.new(data).to_h).to eq(data)
102
73
  end
103
74
  end