gocardless_pro 0.3.0
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 +7 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +146 -0
- data/circle.yml +3 -0
- data/demo.rb +9 -0
- data/gocardless_pro.gemspec +26 -0
- data/lib/gocardless_pro.rb +73 -0
- data/lib/gocardless_pro/api_service.rb +58 -0
- data/lib/gocardless_pro/client.rb +135 -0
- data/lib/gocardless_pro/error.rb +42 -0
- data/lib/gocardless_pro/error/gocardless_error.rb +5 -0
- data/lib/gocardless_pro/error/invalid_api_usage_error.rb +5 -0
- data/lib/gocardless_pro/error/invalid_state_error.rb +5 -0
- data/lib/gocardless_pro/error/validation_error.rb +5 -0
- data/lib/gocardless_pro/list_response.rb +29 -0
- data/lib/gocardless_pro/paginator.rb +43 -0
- data/lib/gocardless_pro/request.rb +69 -0
- data/lib/gocardless_pro/resources/creditor.rb +84 -0
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +78 -0
- data/lib/gocardless_pro/resources/customer.rb +75 -0
- data/lib/gocardless_pro/resources/customer_bank_account.rb +80 -0
- data/lib/gocardless_pro/resources/event.rb +75 -0
- data/lib/gocardless_pro/resources/helper.rb +29 -0
- data/lib/gocardless_pro/resources/mandate.rb +70 -0
- data/lib/gocardless_pro/resources/payment.rb +87 -0
- data/lib/gocardless_pro/resources/payout.rb +66 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +106 -0
- data/lib/gocardless_pro/resources/refund.rb +71 -0
- data/lib/gocardless_pro/resources/subscription.rb +155 -0
- data/lib/gocardless_pro/response.rb +77 -0
- data/lib/gocardless_pro/services/base_service.rb +28 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +119 -0
- data/lib/gocardless_pro/services/creditors_service.rb +113 -0
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +154 -0
- data/lib/gocardless_pro/services/customers_service.rb +113 -0
- data/lib/gocardless_pro/services/events_service.rb +80 -0
- data/lib/gocardless_pro/services/helpers_service.rb +99 -0
- data/lib/gocardless_pro/services/mandates_service.rb +173 -0
- data/lib/gocardless_pro/services/payments_service.rb +168 -0
- data/lib/gocardless_pro/services/payouts_service.rb +82 -0
- data/lib/gocardless_pro/services/redirect_flows_service.rb +98 -0
- data/lib/gocardless_pro/services/refunds_service.rb +132 -0
- data/lib/gocardless_pro/services/subscriptions_service.rb +134 -0
- data/lib/gocardless_pro/version.rb +8 -0
- data/spec/api_service_spec.rb +73 -0
- data/spec/client_spec.rb +19 -0
- data/spec/error_spec.rb +44 -0
- data/spec/resources/creditor_bank_account_spec.rb +109 -0
- data/spec/resources/creditor_spec.rb +125 -0
- data/spec/resources/customer_bank_account_spec.rb +109 -0
- data/spec/resources/customer_spec.rb +135 -0
- data/spec/resources/event_spec.rb +113 -0
- data/spec/resources/helper_spec.rb +23 -0
- data/spec/resources/mandate_spec.rb +97 -0
- data/spec/resources/payment_spec.rb +129 -0
- data/spec/resources/payout_spec.rb +89 -0
- data/spec/resources/redirect_flow_spec.rb +97 -0
- data/spec/resources/refund_spec.rb +77 -0
- data/spec/resources/subscription_spec.rb +165 -0
- data/spec/response_spec.rb +89 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +413 -0
- data/spec/services/creditors_service_spec.rb +388 -0
- data/spec/services/customer_bank_accounts_service_spec.rb +452 -0
- data/spec/services/customers_service_spec.rb +429 -0
- data/spec/services/events_service_spec.rb +217 -0
- data/spec/services/helpers_service_spec.rb +122 -0
- data/spec/services/mandates_service_spec.rb +495 -0
- data/spec/services/payments_service_spec.rb +546 -0
- data/spec/services/payouts_service_spec.rb +217 -0
- data/spec/services/redirect_flows_service_spec.rb +254 -0
- data/spec/services/refunds_service_spec.rb +323 -0
- data/spec/services/subscriptions_service_spec.rb +557 -0
- data/spec/spec_helper.rb +91 -0
- metadata +224 -0
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoCardlessPro::Client do
|
4
|
+
subject { -> { described_class.new(options) } }
|
5
|
+
|
6
|
+
let(:options) do
|
7
|
+
{
|
8
|
+
environment: environment,
|
9
|
+
token: token
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when initialised without an Access Token" do
|
14
|
+
let(:environment) { :live }
|
15
|
+
let(:token) { nil }
|
16
|
+
|
17
|
+
it { is_expected.to raise_error("No Access Token given to GoCardless Client") }
|
18
|
+
end
|
19
|
+
end
|
data/spec/error_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoCardlessPro::Error do
|
4
|
+
subject(:error) { described_class.new(api_error) }
|
5
|
+
|
6
|
+
let(:api_error) do
|
7
|
+
{
|
8
|
+
"documentation_url" => "https://developer.gocardless.com/pro#validation_failed",
|
9
|
+
"message" => "Validation failed",
|
10
|
+
"type" => "validation_failed",
|
11
|
+
"code" => 422,
|
12
|
+
"request_id" => "dd50eaaf-8213-48fe-90d6-5466872efbc4",
|
13
|
+
"errors" => [
|
14
|
+
{
|
15
|
+
"message" => "must be a number",
|
16
|
+
"field" => "branch_code"
|
17
|
+
}, {
|
18
|
+
"message" => "is the wrong length (should be 8 characters)",
|
19
|
+
"field" => "branch_code"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
specify do
|
26
|
+
expect(error.documentation_url).to eq("https://developer.gocardless.com/pro#validation_failed")
|
27
|
+
end
|
28
|
+
|
29
|
+
specify { expect(error.message).to eq("Validation failed") }
|
30
|
+
specify { expect(error.type).to eq("validation_failed") }
|
31
|
+
specify { expect(error.code).to eq(422) }
|
32
|
+
specify { expect(error.request_id).to eq("dd50eaaf-8213-48fe-90d6-5466872efbc4") }
|
33
|
+
specify do
|
34
|
+
expect(error.errors).to eq([
|
35
|
+
{
|
36
|
+
"message" => "must be a number",
|
37
|
+
"field" => "branch_code"
|
38
|
+
}, {
|
39
|
+
"message" => "is the wrong length (should be 8 characters)",
|
40
|
+
"field" => "branch_code"
|
41
|
+
}
|
42
|
+
])
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoCardlessPro::Resources::CreditorBankAccount do
|
4
|
+
describe "initialising" do
|
5
|
+
let(:data) do
|
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
|
+
"creditor" => "creditor-input",
|
44
|
+
|
45
|
+
},
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
"metadata" => "metadata-input",
|
50
|
+
|
51
|
+
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
it "can be initialized from an uneveloped response" do
|
56
|
+
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.creditor).to eq("creditor-input")
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
expect(resource.metadata).to eq("metadata-input")
|
98
|
+
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#to_h" do
|
103
|
+
it "returns a hash representing the resource" do
|
104
|
+
expect(described_class.new(data).to_h).to eq(data)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoCardlessPro::Resources::Creditor do
|
4
|
+
describe "initialising" do
|
5
|
+
let(:data) do
|
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
|
+
"country_code" => "country_code-input",
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
"created_at" => "created_at-input",
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
"id" => "id-input",
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
"links" => {
|
38
|
+
|
39
|
+
"default_eur_payout_account" => "default_eur_payout_account-input",
|
40
|
+
|
41
|
+
"default_gbp_payout_account" => "default_gbp_payout_account-input",
|
42
|
+
|
43
|
+
"logo" => "logo-input",
|
44
|
+
|
45
|
+
},
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
"name" => "name-input",
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
"postal_code" => "postal_code-input",
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
"region" => "region-input",
|
58
|
+
|
59
|
+
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can be initialized from an uneveloped response" do
|
64
|
+
resource = described_class.new(data)
|
65
|
+
|
66
|
+
|
67
|
+
expect(resource.address_line1).to eq("address_line1-input")
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
expect(resource.address_line2).to eq("address_line2-input")
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
expect(resource.address_line3).to eq("address_line3-input")
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
expect(resource.city).to eq("city-input")
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
expect(resource.country_code).to eq("country_code-input")
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
expect(resource.created_at).to eq("created_at-input")
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
expect(resource.id).to eq("id-input")
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
expect(resource.links.default_eur_payout_account).to eq("default_eur_payout_account-input")
|
97
|
+
|
98
|
+
expect(resource.links.default_gbp_payout_account).to eq("default_gbp_payout_account-input")
|
99
|
+
|
100
|
+
expect(resource.links.logo).to eq("logo-input")
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
expect(resource.name).to eq("name-input")
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
expect(resource.postal_code).to eq("postal_code-input")
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
expect(resource.region).to eq("region-input")
|
114
|
+
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#to_h" do
|
119
|
+
it "returns a hash representing the resource" do
|
120
|
+
expect(described_class.new(data).to_h).to eq(data)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoCardlessPro::Resources::CustomerBankAccount do
|
4
|
+
describe "initialising" do
|
5
|
+
let(:data) do
|
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
|
+
|
45
|
+
},
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
"metadata" => "metadata-input",
|
50
|
+
|
51
|
+
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
it "can be initialized from an uneveloped response" do
|
56
|
+
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
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#to_h" do
|
103
|
+
it "returns a hash representing the resource" do
|
104
|
+
expect(described_class.new(data).to_h).to eq(data)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoCardlessPro::Resources::Customer do
|
4
|
+
describe "initialising" do
|
5
|
+
let(:data) do
|
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
|
+
"metadata" => "metadata-input",
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
"postal_code" => "postal_code-input",
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
"region" => "region-input",
|
62
|
+
|
63
|
+
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
it "can be initialized from an uneveloped response" do
|
68
|
+
resource = described_class.new(data)
|
69
|
+
|
70
|
+
|
71
|
+
expect(resource.address_line1).to eq("address_line1-input")
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
expect(resource.address_line2).to eq("address_line2-input")
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
expect(resource.address_line3).to eq("address_line3-input")
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
expect(resource.city).to eq("city-input")
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
expect(resource.company_name).to eq("company_name-input")
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
expect(resource.country_code).to eq("country_code-input")
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
expect(resource.created_at).to eq("created_at-input")
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
expect(resource.email).to eq("email-input")
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
expect(resource.family_name).to eq("family_name-input")
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
expect(resource.given_name).to eq("given_name-input")
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
expect(resource.id).to eq("id-input")
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
expect(resource.metadata).to eq("metadata-input")
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
expect(resource.postal_code).to eq("postal_code-input")
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
expect(resource.region).to eq("region-input")
|
124
|
+
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "#to_h" do
|
129
|
+
it "returns a hash representing the resource" do
|
130
|
+
expect(described_class.new(data).to_h).to eq(data)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|