pactas_itero 0.6.0 → 0.8.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +15 -0
  3. data/.rubocop.yml +765 -0
  4. data/CHANGELOG.md +34 -1
  5. data/Gemfile +3 -1
  6. data/README.md +3 -1
  7. data/Rakefile +7 -4
  8. data/lib/pactas_itero/api/contracts.rb +12 -0
  9. data/lib/pactas_itero/api/customers.rb +2 -0
  10. data/lib/pactas_itero/api/invoices.rb +3 -2
  11. data/lib/pactas_itero/api/oauth.rb +3 -2
  12. data/lib/pactas_itero/api/orders.rb +2 -0
  13. data/lib/pactas_itero/api/rated_items.rb +10 -1
  14. data/lib/pactas_itero/api.rb +9 -7
  15. data/lib/pactas_itero/client.rb +32 -26
  16. data/lib/pactas_itero/configurable.rb +9 -8
  17. data/lib/pactas_itero/default.rb +17 -18
  18. data/lib/pactas_itero/error.rb +45 -44
  19. data/lib/pactas_itero/ext/hash/camelize_keys.rb +12 -10
  20. data/lib/pactas_itero/response/raise_error.rb +5 -5
  21. data/lib/pactas_itero/version.rb +3 -1
  22. data/lib/pactas_itero.rb +5 -3
  23. metadata +16 -83
  24. data/Gemfile.lock +0 -92
  25. data/pactas_itero.gemspec +0 -37
  26. data/spec/fixtures/bearer_token.json +0 -5
  27. data/spec/fixtures/commit_order_response.json +0 -50
  28. data/spec/fixtures/contract.json +0 -46
  29. data/spec/fixtures/contract_cancellation_preview_response.json +0 -73
  30. data/spec/fixtures/contract_termination_response.json +0 -79
  31. data/spec/fixtures/contracts.json +0 -48
  32. data/spec/fixtures/create_order_response.json +0 -17
  33. data/spec/fixtures/create_rated_item.json +0 -8
  34. data/spec/fixtures/customer.json +0 -23
  35. data/spec/fixtures/customers.json +0 -40
  36. data/spec/fixtures/invoice.json +0 -22
  37. data/spec/fixtures/invoice_download.pdf +0 -0
  38. data/spec/fixtures/invoices.json +0 -46
  39. data/spec/fixtures/order.json +0 -15
  40. data/spec/fixtures/payment_transaction.json +0 -37
  41. data/spec/fixtures/rated_items.json +0 -12
  42. data/spec/fixtures/self_service_token.json +0 -6
  43. data/spec/pactas_itero/api/contracts_spec.rb +0 -165
  44. data/spec/pactas_itero/api/customers_spec.rb +0 -229
  45. data/spec/pactas_itero/api/invoices_spec.rb +0 -103
  46. data/spec/pactas_itero/api/oauth_spec.rb +0 -44
  47. data/spec/pactas_itero/api/orders_spec.rb +0 -102
  48. data/spec/pactas_itero/api/payment_transactions_spec.rb +0 -66
  49. data/spec/pactas_itero/api/rated_items_spec.rb +0 -113
  50. data/spec/pactas_itero/client_spec.rb +0 -316
  51. data/spec/pactas_itero_spec.rb +0 -39
  52. data/spec/spec_helper.rb +0 -100
@@ -1,8 +0,0 @@
1
- {
2
- "Description": "the description",
3
- "PeriodEnd": "2014-09-19T08:18:51.907Z",
4
- "PeriodStart": "2014-09-19T08:18:51.907Z",
5
- "PricePerUnit": 123.45,
6
- "Quantity": 2,
7
- "TaxPolicyId": "tax-policy-id"
8
- }
@@ -1,23 +0,0 @@
1
- {
2
- "Address": {
3
- "City": "Example City",
4
- "Country": "DE",
5
- "HouseNumber": "42",
6
- "PostalCode": "12345",
7
- "Street": "Example Street"
8
- },
9
- "CompanyName": "Example Company",
10
- "CreatedAt": "2014-05-12T14:22:24.0000000Z",
11
- "CustomerName": "Example Company",
12
- "CustomerType": "Consumer",
13
- "DefaultBearerMedium": "Email",
14
- "EmailAddress": "jane.doe@example.com",
15
- "ExternalCustomerId": "",
16
- "FirstName": "Jane",
17
- "Id": "5370d9201d8dd006288221b0",
18
- "Language": "de-DE",
19
- "LastName": "Doe",
20
- "Locale": "de-DE",
21
- "VatId": "DE123456710",
22
- "ExternalCustomerId": "1234"
23
- }
@@ -1,40 +0,0 @@
1
- [
2
- {
3
- "Address": {
4
- "City": "Example City",
5
- "Country": "DE",
6
- "HouseNumber": "42",
7
- "PostalCode": "12345",
8
- "Street": "Example Street"
9
- },
10
- "CompanyName": "Example Company",
11
- "CreatedAt": "2014-05-12T14:22:24.0000000Z",
12
- "CustomerName": "Example Company",
13
- "CustomerType": "Consumer",
14
- "DefaultBearerMedium": "Email",
15
- "EmailAddress": "jane.doe@example.com",
16
- "ExternalCustomerId": "",
17
- "FirstName": "Jane",
18
- "Id": "5370d9201d8dd006288221b0",
19
- "Language": "de-DE",
20
- "LastName": "Doe",
21
- "Locale": "de-DE",
22
- "VatId": "DE123456710"
23
- },
24
- {
25
- "Address": {},
26
- "CompanyName": "Test Inc.",
27
- "CreatedAt": "2014-05-14T14:21:20.0000000Z",
28
- "CustomerName": "Test Inc.",
29
- "CustomerType": "Consumer",
30
- "DefaultBearerMedium": "Email",
31
- "EmailAddress": "john.test@example.com",
32
- "ExternalCustomerId": "",
33
- "FirstName": "John",
34
- "Id": "5370d8e01d8dd00628822197",
35
- "Language": "de-DE",
36
- "LastName": "Test",
37
- "Locale": "de-DE",
38
- "VatId": "DE123456789"
39
- }
40
- ]
@@ -1,22 +0,0 @@
1
- {
2
- "Id": "54b67d9e995ec90bc8f37718",
3
- "InvoiceNumber": "SAN//2012//07--2435",
4
- "CustomerId": "54b67d9e675ec90bc8f3770c",
5
- "SentAt": "2012-07-03T23:02:22Z",
6
- "DueDate": "2012-08-02",
7
- "RecipientName": "OldTek GmbH",
8
- "RecipientSubName": "Hermann Anton Müller",
9
- "RecipientAddress": {
10
- "AddressLine1": "c/o Andreas Meister",
11
- "Street": "Sternstraße",
12
- "HouseNumber": "43",
13
- "PostalCode": "80538",
14
- "City": "München",
15
- "Country": "DE"
16
- },
17
- "Currency": "EUR",
18
- "TotalNet": "211.60",
19
- "TotalVat": "40.20",
20
- "TotalGross": "251.80",
21
- "IsInvoice": "False"
22
- }
Binary file
@@ -1,46 +0,0 @@
1
- [
2
- {
3
- "Id": "54b67d9e675ec90bc8f37718",
4
- "InvoiceNumber": "SAN//2012//07--2434",
5
- "CustomerId": "54b67d9e675ec90bc8f3770c",
6
- "SentAt": "2012-07-03T23:02:22Z",
7
- "DueDate": "2012-08-02",
8
- "RecipientName": "OldTek GmbH",
9
- "RecipientSubName": "Hermann Anton Müller",
10
- "RecipientAddress": {
11
- "AddressLine1": "c/o Andreas Meister",
12
- "Street": "Sternstraße",
13
- "HouseNumber": "43",
14
- "PostalCode": "80538",
15
- "City": "München",
16
- "Country": "DE"
17
- },
18
- "Currency": "EUR",
19
- "TotalNet": "211.60",
20
- "TotalVat": "40.20",
21
- "TotalGross": "251.80",
22
- "IsInvoice": "False"
23
- },
24
- {
25
- "Id": "54b67d9e995ec90bc8f37718",
26
- "InvoiceNumber": "SAN//2012//07--2435",
27
- "CustomerId": "54b67d9e675ec90bc8f3770c",
28
- "SentAt": "2012-07-03T23:02:22Z",
29
- "DueDate": "2012-08-02",
30
- "RecipientName": "OldTek GmbH",
31
- "RecipientSubName": "Hermann Anton Müller",
32
- "RecipientAddress": {
33
- "AddressLine1": "c/o Andreas Meister",
34
- "Street": "Sternstraße",
35
- "HouseNumber": "43",
36
- "PostalCode": "80538",
37
- "City": "München",
38
- "Country": "DE"
39
- },
40
- "Currency": "EUR",
41
- "TotalNet": "211.60",
42
- "TotalVat": "40.20",
43
- "TotalGross": "251.80",
44
- "IsInvoice": "False"
45
- }
46
- ]
@@ -1,15 +0,0 @@
1
- {
2
- "Id": "56af22c51d8dd207684db9b5",
3
- "PlanVariantId": "5357b8f11d8dd00fa0db6c1b",
4
- "AllowWithoutPaymentData": false,
5
- "ComponentSubscriptions": [],
6
- "DiscountSubscriptions": [],
7
- "Currency": "EUR",
8
- "Total": 24.9,
9
- "TotalVat": 4.73,
10
- "TotalGross": 29.63,
11
- "IsTrial": false,
12
- "Status": "InProgress",
13
- "CustomerId": "56af224c1d8dd207684db935",
14
- "ContractId": "56af22c51d8dd207684db9b4"
15
- }
@@ -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,6 +0,0 @@
1
- {
2
- "Expiry": "2016-04-07T07:38:49.8019236Z",
3
- "Token": "522703b9eb596a0f40480825$1378374980$JDBWmg34kr_mFIUFP",
4
- "Purpose": "CustomerPortal",
5
- "Url": "https://app.billwerk.com/portal/data/522703b9eb596a0f40480825$1378374980$JDBWIYOmg34kr_mFIUFP/"
6
- }
@@ -1,165 +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 '.contracts' do
33
- it 'requests the correct resource' do
34
- client = PactasItero::Client.new(bearer_token: 'bt')
35
- request = stub_get('/api/v1/contracts').
36
- to_return(
37
- body: fixture('contracts.json'),
38
- headers: { content_type: 'application/json; charset=utf-8'}
39
- )
40
-
41
- client.contracts
42
-
43
- expect(request).to have_been_made
44
- end
45
-
46
- it 'returns an array of contracts' do
47
- client = PactasItero::Client.new(bearer_token: 'bt')
48
- request = stub_get('/api/v1/contracts').
49
- to_return(
50
- body: fixture('contracts.json'),
51
- headers: { content_type: 'application/json; charset=utf-8'}
52
- )
53
-
54
- contracts = client.contracts
55
-
56
- expect(contracts).to be_a Array
57
- end
58
- end
59
-
60
- describe ".contract_cancellation_preview" do
61
- it "requests the correct resource" do
62
- client = PactasItero::Client.new(bearer_token: "bt")
63
- request = stub_get("/api/v1/contracts/some_contract_id/cancellationPreview").to_return(
64
- body: fixture("contract_cancellation_preview_response.json"),
65
- headers: { content_type: "application/json; charset=utf-8" }
66
- )
67
-
68
- client.contract_cancellation_preview("some_contract_id")
69
-
70
- expect(request).to have_been_made
71
- end
72
-
73
- it 'returns the next possible cancellation date' do
74
- client = PactasItero::Client.new(bearer_token: 'bt')
75
- request = stub_get("/api/v1/contracts/some_contract_id/cancellationPreview").to_return(
76
- body: fixture("contract_cancellation_preview_response.json"),
77
- headers: { content_type: "application/json; charset=utf-8" }
78
- )
79
-
80
- contract_cancellation_preview = client.contract_cancellation_preview("some_contract_id")
81
-
82
- expect(
83
- contract_cancellation_preview.next_possible_cancellation_date
84
- ).to eq "2015-11-15T10:02:21.2750000Z"
85
- end
86
- end
87
-
88
- describe '.update_contract' do
89
- it 'requests the correct resource' do
90
- client = PactasItero::Client.new(bearer_token: 'bt')
91
- request = stub_patch('/api/v1/contracts/contract-id').
92
- with(body: { EndDate: '2014-05-23T13:12:47.0760000Z' }.to_json).
93
- to_return(
94
- body: fixture('contract.json'),
95
- headers: { content_type: 'application/json; charset=utf-8'}
96
- )
97
-
98
- client.update_contract('contract-id', { end_date: '2014-05-23T13:12:47.0760000Z' })
99
-
100
- expect(request).to have_been_made
101
- end
102
- end
103
-
104
- describe '.contract' do
105
- it 'requests the correct resource' do
106
- client = PactasItero::Client.new(bearer_token: 'bt')
107
- request = stub_get('/api/v1/contracts/5357bc4f1d8dd00fa0db6c31').
108
- to_return(
109
- body: fixture('contract.json'),
110
- headers: { content_type: 'application/json; charset=utf-8'}
111
- )
112
-
113
- client.contract('5357bc4f1d8dd00fa0db6c31')
114
-
115
- expect(request).to have_been_made
116
- end
117
- end
118
-
119
- describe ".terminate_contract" do
120
- it "requests the correct resource" do
121
- client = PactasItero::Client.new(bearer_token: "bt")
122
- request = stub_post("/api/v1/contracts/5922f50b81b1f007e0e4d738/end").
123
- with(
124
- body: { EndDate: "2017-10-01T14:51:29.3390000Z" }.to_json,
125
- ).
126
- to_return(
127
- body: fixture("contract_termination_response.json"),
128
- headers: { content_type: "application/json; charset=utf-8" },
129
- )
130
-
131
- client.terminate_contract(
132
- "5922f50b81b1f007e0e4d738",
133
- end_date: "2017-10-01T14:51:29.3390000Z",
134
- )
135
-
136
- expect(request).to have_been_made
137
- end
138
- end
139
-
140
- describe ".get_self_service_token_for_contract" do
141
- it "requests the correct resource" do
142
- client = PactasItero::Client.new(bearer_token: "bt")
143
- request = stub_get("/api/v1/contracts/5357bc4f1d8dd00fa0db6c31/SelfServiceToken").to_return(
144
- body: fixture("self_service_token.json"),
145
- headers: { content_type: "application/json; charset=utf-8" },
146
- )
147
-
148
- client.get_self_service_token_for_contract("5357bc4f1d8dd00fa0db6c31")
149
-
150
- expect(request).to have_been_made
151
- end
152
-
153
- it "returns a self service token" do
154
- client = PactasItero::Client.new(bearer_token: "bt")
155
- stub_get("/api/v1/contracts/5357bc4f1d8dd00fa0db6c31/SelfServiceToken").to_return(
156
- body: fixture("self_service_token.json"),
157
- headers: { content_type: "application/json; charset=utf-8" },
158
- )
159
-
160
- self_service_token = client.get_self_service_token_for_contract("5357bc4f1d8dd00fa0db6c31")
161
-
162
- expect(self_service_token.token).to eq "522703b9eb596a0f40480825$1378374980$JDBWmg34kr_mFIUFP"
163
- end
164
- end
165
- end
@@ -1,229 +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('customer-id', {
221
- company_name: 'example & sons',
222
- vat_id: 'DE555',
223
- address: { street: 'abc street' }
224
- })
225
-
226
- expect(request).to have_been_made
227
- end
228
- end
229
- end