pactas_itero 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +15 -0
- data/.rubocop.yml +765 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +2 -0
- data/Rakefile +3 -0
- data/lib/pactas_itero/api/contracts.rb +7 -0
- data/lib/pactas_itero/api/customers.rb +2 -0
- data/lib/pactas_itero/api/invoices.rb +2 -0
- data/lib/pactas_itero/api/oauth.rb +2 -0
- data/lib/pactas_itero/api/orders.rb +2 -0
- data/lib/pactas_itero/api/rated_items.rb +11 -2
- data/lib/pactas_itero/api.rb +2 -0
- data/lib/pactas_itero/client.rb +15 -9
- data/lib/pactas_itero/configurable.rb +8 -5
- data/lib/pactas_itero/default.rb +11 -5
- data/lib/pactas_itero/error.rb +39 -35
- data/lib/pactas_itero/ext/hash/camelize_keys.rb +6 -3
- data/lib/pactas_itero/response/raise_error.rb +3 -1
- data/lib/pactas_itero/version.rb +3 -1
- data/lib/pactas_itero.rb +3 -1
- metadata +11 -83
- data/Gemfile.lock +0 -112
- data/bin/setup +0 -7
- data/pactas_itero.gemspec +0 -37
- data/spec/fixtures/bearer_token.json +0 -5
- data/spec/fixtures/commit_order_response.json +0 -50
- data/spec/fixtures/contract.json +0 -46
- data/spec/fixtures/contract_cancellation_preview_response.json +0 -73
- data/spec/fixtures/contract_changes.json +0 -22
- data/spec/fixtures/contract_termination_response.json +0 -79
- data/spec/fixtures/contracts.json +0 -48
- data/spec/fixtures/create_order_response.json +0 -17
- data/spec/fixtures/create_rated_item.json +0 -8
- data/spec/fixtures/customer.json +0 -23
- data/spec/fixtures/customers.json +0 -40
- data/spec/fixtures/invoice.json +0 -22
- data/spec/fixtures/invoice_download.pdf +0 -0
- data/spec/fixtures/invoices.json +0 -46
- data/spec/fixtures/order.json +0 -15
- data/spec/fixtures/payment_transaction.json +0 -37
- data/spec/fixtures/rated_items.json +0 -12
- data/spec/fixtures/self_service_token.json +0 -6
- data/spec/pactas_itero/api/contracts_spec.rb +0 -193
- data/spec/pactas_itero/api/customers_spec.rb +0 -231
- data/spec/pactas_itero/api/invoices_spec.rb +0 -103
- data/spec/pactas_itero/api/oauth_spec.rb +0 -44
- data/spec/pactas_itero/api/orders_spec.rb +0 -102
- data/spec/pactas_itero/api/payment_transactions_spec.rb +0 -66
- data/spec/pactas_itero/api/rated_items_spec.rb +0 -113
- data/spec/pactas_itero/client_spec.rb +0 -312
- data/spec/pactas_itero_spec.rb +0 -37
- data/spec/spec_helper.rb +0 -100
- data/yarn-error.log +0 -43
@@ -1,37 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"Amount": 11.89,
|
3
|
-
"ContractId": "592d74a981b1f010f04293a4",
|
4
|
-
"Currency": "EUR",
|
5
|
-
"CustomerId": "592d74a881b1f010f04293a2",
|
6
|
-
"CustomerName": "Example Company",
|
7
|
-
"Id": "597de03d81b1ef0d18a46f4e",
|
8
|
-
"PaymentProvider": "Example Provider",
|
9
|
-
"PaymentProviderRole": "CreditCard",
|
10
|
-
"Preauth": false,
|
11
|
-
"ProviderTransactionId": "ccec718e-271e-4d0e-b0e1-94894e40c0c7",
|
12
|
-
"Status": {
|
13
|
-
"Amount": 11.89,
|
14
|
-
"HttpCode": 0,
|
15
|
-
"Preauth": false,
|
16
|
-
"Status": "Succeeded",
|
17
|
-
"Timestamp": "2017-07-30T13:33:49.9900000Z"
|
18
|
-
},
|
19
|
-
"StatusHistory": [
|
20
|
-
{
|
21
|
-
"Amount": 11.89,
|
22
|
-
"HttpCode": 0,
|
23
|
-
"Preauth": false,
|
24
|
-
"Status": "InProgress",
|
25
|
-
"Timestamp": "2017-07-30T13:33:49.9760000Z"
|
26
|
-
},
|
27
|
-
{
|
28
|
-
"Amount": 11.89,
|
29
|
-
"HttpCode": 0,
|
30
|
-
"Preauth": false,
|
31
|
-
"Status": "Succeeded",
|
32
|
-
"Timestamp": "2017-07-30T13:33:49.9900000Z"
|
33
|
-
}
|
34
|
-
],
|
35
|
-
"StatusTimestamp": "2017-07-30T13:33:49.9900000Z",
|
36
|
-
"Trigger": "Recurring"
|
37
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"id": "591b847314aa03167c5a3b08",
|
4
|
-
"line_item_id": "59308e9781b1ef1190f21478",
|
5
|
-
"description": "1x DHL Versandmarken",
|
6
|
-
"quantity": 1,
|
7
|
-
"price_per_unit": 3.9,
|
8
|
-
"tax_policy_id": "tax-policy-id",
|
9
|
-
"period_start": "2017-05-15T22:00:00.0000000Z",
|
10
|
-
"period_end": "2017-05-15T22:00:00.0000000Z"
|
11
|
-
}
|
12
|
-
]
|
@@ -1,193 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe PactasItero::Api::Customers do
|
4
|
-
describe ".customer_contracts" do
|
5
|
-
it "requests the correct resource" do
|
6
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
7
|
-
request = stub_get("/api/v1/customers/535783241d8dd00fa0db6b2a/contracts").
|
8
|
-
to_return(
|
9
|
-
body: fixture("contracts.json"),
|
10
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
11
|
-
)
|
12
|
-
|
13
|
-
client.customer_contracts("535783241d8dd00fa0db6b2a")
|
14
|
-
|
15
|
-
expect(request).to have_been_made
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns an array of contracts" do
|
19
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
20
|
-
request = stub_get("/api/v1/customers/535783241d8dd00fa0db6b2a/contracts").
|
21
|
-
to_return(
|
22
|
-
body: fixture("contracts.json"),
|
23
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
24
|
-
)
|
25
|
-
|
26
|
-
contracts = client.customer_contracts("535783241d8dd00fa0db6b2a")
|
27
|
-
|
28
|
-
expect(contracts).to be_a Array
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe ".contract_changes" do
|
33
|
-
it "requests the correct resource" do
|
34
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
35
|
-
request = stub_get("/api/v1/contractChanges?contractId=5357bc4f1d8dd00fa0db6c31").
|
36
|
-
to_return(
|
37
|
-
body: fixture("contract_changes.json"),
|
38
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
39
|
-
)
|
40
|
-
|
41
|
-
client.contract_changes("5357bc4f1d8dd00fa0db6c31")
|
42
|
-
|
43
|
-
expect(request).to have_been_made
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns an array of contract changes" do
|
47
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
48
|
-
stub_get("/api/v1/contractChanges?contractId=5357bc4f1d8dd00fa0db6c31").
|
49
|
-
to_return(
|
50
|
-
body: fixture("contract_changes.json"),
|
51
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
52
|
-
)
|
53
|
-
|
54
|
-
contract_changes = client.contract_changes("5357bc4f1d8dd00fa0db6c31")
|
55
|
-
|
56
|
-
expect(contract_changes).to be_a Array
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe ".contracts" do
|
61
|
-
it "requests the correct resource" do
|
62
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
63
|
-
request = stub_get("/api/v1/contracts").
|
64
|
-
to_return(
|
65
|
-
body: fixture("contracts.json"),
|
66
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
67
|
-
)
|
68
|
-
|
69
|
-
client.contracts
|
70
|
-
|
71
|
-
expect(request).to have_been_made
|
72
|
-
end
|
73
|
-
|
74
|
-
it "returns an array of contracts" do
|
75
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
76
|
-
request = stub_get("/api/v1/contracts").
|
77
|
-
to_return(
|
78
|
-
body: fixture("contracts.json"),
|
79
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
80
|
-
)
|
81
|
-
|
82
|
-
contracts = client.contracts
|
83
|
-
|
84
|
-
expect(contracts).to be_a Array
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe ".contract_cancellation_preview" do
|
89
|
-
it "requests the correct resource" do
|
90
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
91
|
-
request = stub_get("/api/v1/contracts/some_contract_id/cancellationPreview").to_return(
|
92
|
-
body: fixture("contract_cancellation_preview_response.json"),
|
93
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
94
|
-
)
|
95
|
-
|
96
|
-
client.contract_cancellation_preview("some_contract_id")
|
97
|
-
|
98
|
-
expect(request).to have_been_made
|
99
|
-
end
|
100
|
-
|
101
|
-
it "returns the next possible cancellation date" do
|
102
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
103
|
-
request = stub_get("/api/v1/contracts/some_contract_id/cancellationPreview").to_return(
|
104
|
-
body: fixture("contract_cancellation_preview_response.json"),
|
105
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
106
|
-
)
|
107
|
-
|
108
|
-
contract_cancellation_preview = client.contract_cancellation_preview("some_contract_id")
|
109
|
-
|
110
|
-
expect(
|
111
|
-
contract_cancellation_preview.next_possible_cancellation_date,
|
112
|
-
).to eq "2015-11-15T10:02:21.2750000Z"
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe ".update_contract" do
|
117
|
-
it "requests the correct resource" do
|
118
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
119
|
-
request = stub_patch("/api/v1/contracts/contract-id").
|
120
|
-
with(body: { EndDate: "2014-05-23T13:12:47.0760000Z" }.to_json).
|
121
|
-
to_return(
|
122
|
-
body: fixture("contract.json"),
|
123
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
124
|
-
)
|
125
|
-
|
126
|
-
client.update_contract("contract-id", { end_date: "2014-05-23T13:12:47.0760000Z" })
|
127
|
-
|
128
|
-
expect(request).to have_been_made
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe ".contract" do
|
133
|
-
it "requests the correct resource" do
|
134
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
135
|
-
request = stub_get("/api/v1/contracts/5357bc4f1d8dd00fa0db6c31").
|
136
|
-
to_return(
|
137
|
-
body: fixture("contract.json"),
|
138
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
139
|
-
)
|
140
|
-
|
141
|
-
client.contract("5357bc4f1d8dd00fa0db6c31")
|
142
|
-
|
143
|
-
expect(request).to have_been_made
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe ".terminate_contract" do
|
148
|
-
it "requests the correct resource" do
|
149
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
150
|
-
request = stub_post("/api/v1/contracts/5922f50b81b1f007e0e4d738/end").
|
151
|
-
with(
|
152
|
-
body: { EndDate: "2017-10-01T14:51:29.3390000Z" }.to_json,
|
153
|
-
).
|
154
|
-
to_return(
|
155
|
-
body: fixture("contract_termination_response.json"),
|
156
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
157
|
-
)
|
158
|
-
|
159
|
-
client.terminate_contract(
|
160
|
-
"5922f50b81b1f007e0e4d738",
|
161
|
-
end_date: "2017-10-01T14:51:29.3390000Z",
|
162
|
-
)
|
163
|
-
|
164
|
-
expect(request).to have_been_made
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe ".get_self_service_token_for_contract" do
|
169
|
-
it "requests the correct resource" do
|
170
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
171
|
-
request = stub_get("/api/v1/contracts/5357bc4f1d8dd00fa0db6c31/SelfServiceToken").to_return(
|
172
|
-
body: fixture("self_service_token.json"),
|
173
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
174
|
-
)
|
175
|
-
|
176
|
-
client.get_self_service_token_for_contract("5357bc4f1d8dd00fa0db6c31")
|
177
|
-
|
178
|
-
expect(request).to have_been_made
|
179
|
-
end
|
180
|
-
|
181
|
-
it "returns a self service token" do
|
182
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
183
|
-
stub_get("/api/v1/contracts/5357bc4f1d8dd00fa0db6c31/SelfServiceToken").to_return(
|
184
|
-
body: fixture("self_service_token.json"),
|
185
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
186
|
-
)
|
187
|
-
|
188
|
-
self_service_token = client.get_self_service_token_for_contract("5357bc4f1d8dd00fa0db6c31")
|
189
|
-
|
190
|
-
expect(self_service_token.token).to eq "522703b9eb596a0f40480825$1378374980$JDBWmg34kr_mFIUFP"
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
@@ -1,231 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe PactasItero::Api::Customers do
|
4
|
-
describe ".create_customer" do
|
5
|
-
it "requests the correct resource" do
|
6
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
7
|
-
post_data = {
|
8
|
-
"Address" => {
|
9
|
-
"City" => "Example City",
|
10
|
-
"Country" => "DE",
|
11
|
-
"HouseNumber" => "42",
|
12
|
-
"PostalCode" => "12345",
|
13
|
-
"Street" => "Example Street",
|
14
|
-
},
|
15
|
-
"CompanyName" => "Example Company",
|
16
|
-
"DefaultBearerMedium" => "Email",
|
17
|
-
"EmailAddress" => "jane.doe@example.com",
|
18
|
-
"ExternalCustomerId" => "1234",
|
19
|
-
"FirstName" => "Jane",
|
20
|
-
"Language" => "de-DE",
|
21
|
-
"LastName" => "Doe",
|
22
|
-
"Locale" => "de-DE",
|
23
|
-
"VatId" => "DE123456710",
|
24
|
-
}.to_json
|
25
|
-
request = stub_post("/api/v1/customers").with(body: post_data).to_return(
|
26
|
-
body: fixture("customer.json"),
|
27
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
28
|
-
)
|
29
|
-
|
30
|
-
client.create_customer(
|
31
|
-
address: {
|
32
|
-
city: "Example City",
|
33
|
-
country: "DE",
|
34
|
-
house_number: "42",
|
35
|
-
postal_code: "12345",
|
36
|
-
street: "Example Street",
|
37
|
-
},
|
38
|
-
company_name: "Example Company",
|
39
|
-
default_bearer_medium: "Email",
|
40
|
-
email_address: "jane.doe@example.com",
|
41
|
-
external_customer_id: "1234",
|
42
|
-
first_name: "Jane",
|
43
|
-
language: "de-DE",
|
44
|
-
last_name: "Doe",
|
45
|
-
locale: "de-DE",
|
46
|
-
vat_id: "DE123456710",
|
47
|
-
)
|
48
|
-
|
49
|
-
expect(request).to have_been_made
|
50
|
-
end
|
51
|
-
|
52
|
-
it "returns the created customer" do
|
53
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
54
|
-
post_data = {
|
55
|
-
"Address" => {
|
56
|
-
"City" => "Example City",
|
57
|
-
"Country" => "DE",
|
58
|
-
"HouseNumber" => "42",
|
59
|
-
"PostalCode" => "12345",
|
60
|
-
"Street" => "Example Street",
|
61
|
-
},
|
62
|
-
"CompanyName" => "Example Company",
|
63
|
-
"DefaultBearerMedium" => "Email",
|
64
|
-
"EmailAddress" => "jane.doe@example.com",
|
65
|
-
"ExternalCustomerId" => "1234",
|
66
|
-
"FirstName" => "Jane",
|
67
|
-
"Language" => "de-DE",
|
68
|
-
"LastName" => "Doe",
|
69
|
-
"Locale" => "de-DE",
|
70
|
-
"VatId" => "DE123456710",
|
71
|
-
}.to_json
|
72
|
-
request = stub_post("/api/v1/customers").with(body: post_data).to_return(
|
73
|
-
body: fixture("customer.json"),
|
74
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
75
|
-
)
|
76
|
-
|
77
|
-
customer = client.create_customer(
|
78
|
-
address: {
|
79
|
-
city: "Example City",
|
80
|
-
country: "DE",
|
81
|
-
house_number: "42",
|
82
|
-
postal_code: "12345",
|
83
|
-
street: "Example Street",
|
84
|
-
},
|
85
|
-
company_name: "Example Company",
|
86
|
-
default_bearer_medium: "Email",
|
87
|
-
email_address: "jane.doe@example.com",
|
88
|
-
external_customer_id: "1234",
|
89
|
-
first_name: "Jane",
|
90
|
-
language: "de-DE",
|
91
|
-
last_name: "Doe",
|
92
|
-
locale: "de-DE",
|
93
|
-
vat_id: "DE123456710",
|
94
|
-
)
|
95
|
-
|
96
|
-
address = customer.address
|
97
|
-
expect(address.city).to eq "Example City"
|
98
|
-
expect(address.country).to eq "DE"
|
99
|
-
expect(address.house_number).to eq "42"
|
100
|
-
expect(address.postal_code).to eq "12345"
|
101
|
-
expect(address.street).to eq "Example Street"
|
102
|
-
|
103
|
-
expect(customer.company_name).to eq "Example Company"
|
104
|
-
expect(customer.default_bearer_medium).to eq "Email"
|
105
|
-
expect(customer.email_address).to eq "jane.doe@example.com"
|
106
|
-
expect(customer.external_customer_id).to eq "1234"
|
107
|
-
expect(customer.first_name).to eq "Jane"
|
108
|
-
expect(customer.language).to eq "de-DE"
|
109
|
-
expect(customer.last_name).to eq "Doe"
|
110
|
-
expect(customer.locale).to eq "de-DE"
|
111
|
-
expect(customer.vat_id).to eq "DE123456710"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe ".customers" do
|
116
|
-
it "requests the correct resource" do
|
117
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
118
|
-
request = stub_get("/api/v1/customers").
|
119
|
-
to_return(
|
120
|
-
body: fixture("customers.json"),
|
121
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
122
|
-
)
|
123
|
-
|
124
|
-
client.customers
|
125
|
-
|
126
|
-
expect(request).to have_been_made
|
127
|
-
end
|
128
|
-
|
129
|
-
it "returns an array of customers" do
|
130
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
131
|
-
request = stub_get("/api/v1/customers").
|
132
|
-
to_return(
|
133
|
-
body: fixture("customers.json"),
|
134
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
135
|
-
)
|
136
|
-
|
137
|
-
customers = client.customers
|
138
|
-
|
139
|
-
expect(customers).to be_a Array
|
140
|
-
customer = customers.first
|
141
|
-
|
142
|
-
expect(customer.company_name).to eq "Example Company"
|
143
|
-
expect(customer.created_at).to eq "2014-05-12T14:22:24.0000000Z"
|
144
|
-
expect(customer.customer_name).to eq "Example Company"
|
145
|
-
expect(customer.customer_type).to eq "Consumer"
|
146
|
-
expect(customer.default_bearer_medium).to eq "Email"
|
147
|
-
expect(customer.email_address).to eq "jane.doe@example.com"
|
148
|
-
expect(customer.external_customer_id).to eq ""
|
149
|
-
expect(customer.first_name).to eq "Jane"
|
150
|
-
expect(customer.id).to eq "5370d9201d8dd006288221b0"
|
151
|
-
expect(customer.language).to eq "de-DE"
|
152
|
-
expect(customer.last_name).to eq "Doe"
|
153
|
-
expect(customer.locale).to eq "de-DE"
|
154
|
-
expect(customer.vat_id).to eq "DE123456710"
|
155
|
-
expect(customer.address.city).to eq "Example City"
|
156
|
-
expect(customer.address.country).to eq "DE"
|
157
|
-
expect(customer.address.house_number).to eq "42"
|
158
|
-
expect(customer.address.postal_code).to eq "12345"
|
159
|
-
expect(customer.address.street).to eq "Example Street"
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe ".customer" do
|
164
|
-
it "requests the correct resource" do
|
165
|
-
client = PactasItero::Client.new(bearer_token: "bearer_token")
|
166
|
-
request = stub_get("/api/v1/customers/customer-id").to_return(
|
167
|
-
body: fixture("customer.json"),
|
168
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
169
|
-
)
|
170
|
-
|
171
|
-
client.customer("customer-id")
|
172
|
-
|
173
|
-
expect(request).to have_been_made
|
174
|
-
end
|
175
|
-
|
176
|
-
it "returns the customer details" do
|
177
|
-
client = PactasItero::Client.new(bearer_token: "bearer_token")
|
178
|
-
stub_get("/api/v1/customers/customer-id").to_return(
|
179
|
-
body: fixture("customer.json"),
|
180
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
181
|
-
)
|
182
|
-
|
183
|
-
customer = client.customer("customer-id")
|
184
|
-
|
185
|
-
address = customer.address
|
186
|
-
expect(address.city).to eq "Example City"
|
187
|
-
expect(address.country).to eq "DE"
|
188
|
-
expect(address.house_number).to eq "42"
|
189
|
-
expect(address.postal_code).to eq "12345"
|
190
|
-
expect(address.street).to eq "Example Street"
|
191
|
-
|
192
|
-
expect(customer.company_name).to eq "Example Company"
|
193
|
-
expect(customer.default_bearer_medium).to eq "Email"
|
194
|
-
expect(customer.email_address).to eq "jane.doe@example.com"
|
195
|
-
expect(customer.external_customer_id).to eq "1234"
|
196
|
-
expect(customer.first_name).to eq "Jane"
|
197
|
-
expect(customer.language).to eq "de-DE"
|
198
|
-
expect(customer.last_name).to eq "Doe"
|
199
|
-
expect(customer.locale).to eq "de-DE"
|
200
|
-
expect(customer.vat_id).to eq "DE123456710"
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
describe ".update_customer" do
|
205
|
-
it "requests the correct resource" do
|
206
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
207
|
-
request = stub_patch("/api/v1/customers/customer-id").
|
208
|
-
with(
|
209
|
-
body: {
|
210
|
-
CompanyName: "example & sons",
|
211
|
-
VatId: "DE555",
|
212
|
-
Address: { Street: "abc street" },
|
213
|
-
}.to_json,
|
214
|
-
).
|
215
|
-
to_return(
|
216
|
-
body: fixture("customer.json"),
|
217
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
218
|
-
)
|
219
|
-
|
220
|
-
client.update_customer(
|
221
|
-
"customer-id", {
|
222
|
-
company_name: "example & sons",
|
223
|
-
vat_id: "DE555",
|
224
|
-
address: { street: "abc street" },
|
225
|
-
}
|
226
|
-
)
|
227
|
-
|
228
|
-
expect(request).to have_been_made
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe PactasItero::Api::Invoices do
|
4
|
-
describe ".invoices" do
|
5
|
-
it "requests the correct resource" do
|
6
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
7
|
-
request = stub_get("/api/v1/invoices").
|
8
|
-
to_return(
|
9
|
-
body: fixture("invoices.json"),
|
10
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
11
|
-
)
|
12
|
-
|
13
|
-
client.invoices
|
14
|
-
|
15
|
-
expect(request).to have_been_made
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns an array of contracts" do
|
19
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
20
|
-
request = stub_get("/api/v1/invoices").
|
21
|
-
to_return(
|
22
|
-
body: fixture("invoices.json"),
|
23
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
24
|
-
)
|
25
|
-
|
26
|
-
invoices = client.invoices
|
27
|
-
|
28
|
-
expect(invoices).to be_a Array
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe ".invoices_from" do
|
33
|
-
it "requests the correct resource" do
|
34
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
35
|
-
request = stub_get("/api/v1/invoices?from=54b67d9e995ec90bc8f37718").
|
36
|
-
to_return(
|
37
|
-
body: fixture("invoices.json"),
|
38
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
39
|
-
)
|
40
|
-
|
41
|
-
client.invoices_from("54b67d9e995ec90bc8f37718")
|
42
|
-
|
43
|
-
expect(request).to have_been_made
|
44
|
-
end
|
45
|
-
|
46
|
-
it "requests the correct resource, if from parameter is nil" do
|
47
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
48
|
-
request = stub_get("/api/v1/invoices").
|
49
|
-
to_return(
|
50
|
-
body: fixture("invoices.json"),
|
51
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
52
|
-
)
|
53
|
-
|
54
|
-
client.invoices_from(nil)
|
55
|
-
|
56
|
-
expect(request).to have_been_made
|
57
|
-
end
|
58
|
-
|
59
|
-
it "returns an array of contracts" do
|
60
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
61
|
-
request = stub_get("/api/v1/invoices?from=54b67d9e995ec90bc8f37718").
|
62
|
-
to_return(
|
63
|
-
body: fixture("invoices.json"),
|
64
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
65
|
-
)
|
66
|
-
|
67
|
-
invoices = client.invoices_from("54b67d9e995ec90bc8f37718")
|
68
|
-
|
69
|
-
expect(invoices).to be_a Array
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe ".invoice" do
|
74
|
-
it "requests the correct resource" do
|
75
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
76
|
-
request = stub_get("/api/v1/invoices/54b67d9e995ec90bc8f37718").
|
77
|
-
to_return(
|
78
|
-
body: fixture("invoice.json"),
|
79
|
-
headers: { content_type: "application/json; charset=utf-8" },
|
80
|
-
)
|
81
|
-
|
82
|
-
client.invoice("54b67d9e995ec90bc8f37718")
|
83
|
-
|
84
|
-
expect(request).to have_been_made
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe ".invoice_download" do
|
89
|
-
it "returns the pdf as a string after requesting the correct resource" do
|
90
|
-
client = PactasItero::Client.new(bearer_token: "bt")
|
91
|
-
request = stub_get("/api/v1/invoices/54b67d9e995ec90bc8f37718/download").
|
92
|
-
to_return(
|
93
|
-
body: fixture("invoice_download.pdf"),
|
94
|
-
headers: { content_type: "application/pdf" },
|
95
|
-
)
|
96
|
-
|
97
|
-
response = client.invoice_download("54b67d9e995ec90bc8f37718")
|
98
|
-
|
99
|
-
expect(request).to have_been_made
|
100
|
-
expect(response.class).to be String
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe PactasItero::Api::OAuth do
|
4
|
-
describe "#token" do
|
5
|
-
it "requests the correct resource" do
|
6
|
-
client_credentials_request = stub_post("https://sandbox.billwerk.com/oauth/token").with(
|
7
|
-
basic_auth: %w(a_client_id a_client_secret),
|
8
|
-
body: "grant_type=client_credentials",
|
9
|
-
headers: {
|
10
|
-
"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8",
|
11
|
-
},
|
12
|
-
)
|
13
|
-
|
14
|
-
client = PactasItero::Client.new(client_id: "a_client_id", client_secret: "a_client_secret")
|
15
|
-
|
16
|
-
client.token
|
17
|
-
|
18
|
-
expect(client_credentials_request).to have_been_made
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns the bearer token" do
|
22
|
-
stub_post("https://sandbox.billwerk.com/oauth/token").with(
|
23
|
-
basic_auth: %w(a_client_id a_client_secret),
|
24
|
-
body: "grant_type=client_credentials",
|
25
|
-
headers: {
|
26
|
-
"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8",
|
27
|
-
},
|
28
|
-
).to_return(
|
29
|
-
status: 200,
|
30
|
-
body: fixture("bearer_token.json"),
|
31
|
-
headers: {
|
32
|
-
content_type: "application/json; charset=utf-8",
|
33
|
-
},
|
34
|
-
)
|
35
|
-
|
36
|
-
client = PactasItero::Client.new(client_id: "a_client_id", client_secret: "a_client_secret")
|
37
|
-
bearer_token = client.token
|
38
|
-
|
39
|
-
expect(bearer_token.access_token).to eq("top_secret_access_token")
|
40
|
-
expect(bearer_token.token_type).to eq("bearer")
|
41
|
-
expect(bearer_token.expires).to eq(0)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|