pactas_itero 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +1,27 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
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
- )
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
12
 
13
13
  client.invoices
14
14
 
15
15
  expect(request).to have_been_made
16
16
  end
17
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
- )
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
25
 
26
26
  invoices = client.invoices
27
27
 
@@ -29,72 +29,72 @@ describe PactasItero::Api::Invoices do
29
29
  end
30
30
  end
31
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
- )
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
40
 
41
- client.invoices_from('54b67d9e995ec90bc8f37718')
41
+ client.invoices_from("54b67d9e995ec90bc8f37718")
42
42
 
43
43
  expect(request).to have_been_made
44
44
  end
45
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
- )
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
53
 
54
54
  client.invoices_from(nil)
55
55
 
56
56
  expect(request).to have_been_made
57
57
  end
58
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
- )
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
66
 
67
- invoices = client.invoices_from('54b67d9e995ec90bc8f37718')
67
+ invoices = client.invoices_from("54b67d9e995ec90bc8f37718")
68
68
 
69
69
  expect(invoices).to be_a Array
70
70
  end
71
71
  end
72
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
- )
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
81
 
82
- client.invoice('54b67d9e995ec90bc8f37718')
82
+ client.invoice("54b67d9e995ec90bc8f37718")
83
83
 
84
84
  expect(request).to have_been_made
85
85
  end
86
86
  end
87
87
 
88
- describe '.invoice_download' do
88
+ describe ".invoice_download" do
89
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').
90
+ client = PactasItero::Client.new(bearer_token: "bt")
91
+ request = stub_get("/api/v1/invoices/54b67d9e995ec90bc8f37718/download").
92
92
  to_return(
93
- body: fixture('invoice_download.pdf'),
94
- headers: { content_type: 'application/pdf'}
93
+ body: fixture("invoice_download.pdf"),
94
+ headers: { content_type: "application/pdf" },
95
95
  )
96
96
 
97
- response = client.invoice_download('54b67d9e995ec90bc8f37718')
97
+ response = client.invoice_download("54b67d9e995ec90bc8f37718")
98
98
 
99
99
  expect(request).to have_been_made
100
100
  expect(response.class).to be String
@@ -1,69 +1,69 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe PactasItero::Api::Orders do
4
4
  describe ".create_order" do
5
5
  it "requests the correct resource" do
6
- client = PactasItero::Client.new(bearer_token: 'bt')
6
+ client = PactasItero::Client.new(bearer_token: "bt")
7
7
  post_data = {
8
8
  ContractId: "5370e5ab9e40071fd01e01e0",
9
9
  Cart: {
10
- PlanVariantId: "525bf9089e40073a58590fd5"
11
- }
10
+ PlanVariantId: "525bf9089e40073a58590fd5",
11
+ },
12
12
  }.to_json
13
- request = stub_post('/api/v1/orders').
13
+ request = stub_post("/api/v1/orders").
14
14
  with(body: post_data).
15
15
  to_return(
16
- body: fixture('create_order_response.json'),
17
- headers: { content_type: 'application/json; charset=utf-8'}
16
+ body: fixture("create_order_response.json"),
17
+ headers: { content_type: "application/json; charset=utf-8" },
18
18
  )
19
19
 
20
20
  client.create_order(
21
21
  contract_id: "5370e5ab9e40071fd01e01e0",
22
22
  cart: {
23
- plan_variant_id: "525bf9089e40073a58590fd5"
24
- }
23
+ plan_variant_id: "525bf9089e40073a58590fd5",
24
+ },
25
25
  )
26
26
 
27
27
  expect(request).to have_been_made
28
28
  end
29
29
 
30
- it 'returns the created order' do
31
- client = PactasItero::Client.new(bearer_token: 'bt')
30
+ it "returns the created order" do
31
+ client = PactasItero::Client.new(bearer_token: "bt")
32
32
  post_data = {
33
33
  ContractId: "5370e5ab9e40071fd01e01e0",
34
34
  Cart: {
35
- PlanVariantId: "525bf9089e40073a58590fd5"
36
- }
35
+ PlanVariantId: "525bf9089e40073a58590fd5",
36
+ },
37
37
  }.to_json
38
- request = stub_post('/api/v1/orders').
38
+ request = stub_post("/api/v1/orders").
39
39
  with(body: post_data).
40
40
  to_return(
41
- body: fixture('create_order_response.json'),
42
- headers: { content_type: 'application/json; charset=utf-8'}
41
+ body: fixture("create_order_response.json"),
42
+ headers: { content_type: "application/json; charset=utf-8" },
43
43
  )
44
44
 
45
45
  order = client.create_order(
46
46
  contract_id: "5370e5ab9e40071fd01e01e0",
47
47
  cart: {
48
- plan_variant_id: "525bf9089e40073a58590fd5"
49
- }
48
+ plan_variant_id: "525bf9089e40073a58590fd5",
49
+ },
50
50
  )
51
51
 
52
- expect(order.id).to eq '537dfcab9e400760b4cd6347'
53
- expect(order.contract_id).to eq '5370e5ab9e40071fd01e01e0'
52
+ expect(order.id).to eq "537dfcab9e400760b4cd6347"
53
+ expect(order.contract_id).to eq "5370e5ab9e40071fd01e01e0"
54
54
  end
55
55
  end
56
56
 
57
- describe '.order' do
58
- it 'requests the correct resource' do
59
- client = PactasItero::Client.new(bearer_token: 'bt')
60
- request = stub_get('/api/v1/orders/5357bc4f1d8dd00fa0db6c31').
61
- to_return(
62
- body: fixture('order.json'),
63
- headers: { content_type: 'application/json; charset=utf-8'}
64
- )
57
+ describe ".order" do
58
+ it "requests the correct resource" do
59
+ client = PactasItero::Client.new(bearer_token: "bt")
60
+ request = stub_get("/api/v1/orders/5357bc4f1d8dd00fa0db6c31").
61
+ to_return(
62
+ body: fixture("order.json"),
63
+ headers: { content_type: "application/json; charset=utf-8" },
64
+ )
65
65
 
66
- client.order('5357bc4f1d8dd00fa0db6c31')
66
+ client.order("5357bc4f1d8dd00fa0db6c31")
67
67
 
68
68
  expect(request).to have_been_made
69
69
  end
@@ -71,32 +71,32 @@ describe PactasItero::Api::Orders do
71
71
 
72
72
  describe ".commit_order" do
73
73
  it "requests the correct resource" do
74
- client = PactasItero::Client.new(bearer_token: 'bt')
75
- request = stub_post('/api/v1/orders/537dfcab9e400760b4cd6347/commit').
74
+ client = PactasItero::Client.new(bearer_token: "bt")
75
+ request = stub_post("/api/v1/orders/537dfcab9e400760b4cd6347/commit").
76
76
  with(body: {}.to_json).
77
77
  to_return(
78
- body: fixture('commit_order_response.json'),
79
- headers: { content_type: 'application/json; charset=utf-8'}
78
+ body: fixture("commit_order_response.json"),
79
+ headers: { content_type: "application/json; charset=utf-8" },
80
80
  )
81
81
 
82
- client.commit_order('537dfcab9e400760b4cd6347')
82
+ client.commit_order("537dfcab9e400760b4cd6347")
83
83
 
84
84
  expect(request).to have_been_made
85
85
  end
86
86
 
87
- it 'returns the updated contract' do
88
- client = PactasItero::Client.new(bearer_token: 'bt')
89
- request = stub_post('/api/v1/orders/537dfcab9e400760b4cd6347/commit').
87
+ it "returns the updated contract" do
88
+ client = PactasItero::Client.new(bearer_token: "bt")
89
+ request = stub_post("/api/v1/orders/537dfcab9e400760b4cd6347/commit").
90
90
  with(body: {}.to_json).
91
91
  to_return(
92
- body: fixture('commit_order_response.json'),
93
- headers: { content_type: 'application/json; charset=utf-8'}
92
+ body: fixture("commit_order_response.json"),
93
+ headers: { content_type: "application/json; charset=utf-8" },
94
94
  )
95
95
 
96
- contract = client.commit_order('537dfcab9e400760b4cd6347')
96
+ contract = client.commit_order("537dfcab9e400760b4cd6347")
97
97
 
98
- expect(contract.id).to eq '5370e5ab9e40071fd01e01e0'
99
- expect(contract.current_phase.plan_variant_id).to eq '525bf9089e40073a58590fd5'
98
+ expect(contract.id).to eq "5370e5ab9e40071fd01e01e0"
99
+ expect(contract.current_phase.plan_variant_id).to eq "525bf9089e40073a58590fd5"
100
100
  end
101
101
  end
102
102
  end
@@ -1,84 +1,84 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe PactasItero::Api::RatedItems do
4
4
  describe ".create_rated_item" do
5
5
  it "requests the correct resource" do
6
- client = PactasItero::Client.new(bearer_token: 'bt')
6
+ client = PactasItero::Client.new(bearer_token: "bt")
7
7
  post_data = {
8
- PeriodStart: '2014-09-19T08:18:51.907Z',
9
- PeriodEnd: '2014-09-19T08:19:51.907Z',
8
+ PeriodStart: "2014-09-19T08:18:51.907Z",
9
+ PeriodEnd: "2014-09-19T08:19:51.907Z",
10
10
  Quantity: 2,
11
- Description: 'the description',
11
+ Description: "the description",
12
12
  PricePerUnit: 123.45,
13
- TaxPolicyId: 'tax-policy-id',
13
+ TaxPolicyId: "tax-policy-id",
14
14
  }.to_json
15
- request = stub_post('/api/v1/contracts/contract-id/ratedItems').
16
- with(body: post_data).
17
- to_return(
18
- body: fixture('create_rated_item.json'),
19
- headers: { content_type: 'application/json; charset=utf-8'}
20
- )
15
+ request = stub_post("/api/v1/contracts/contract-id/ratedItems").
16
+ with(body: post_data).
17
+ to_return(
18
+ body: fixture("create_rated_item.json"),
19
+ headers: { content_type: "application/json; charset=utf-8" },
20
+ )
21
21
 
22
22
  client.create_rated_item(
23
- 'contract-id',
23
+ "contract-id",
24
24
  2,
25
- 'the description',
25
+ "the description",
26
26
  123.45,
27
- 'tax-policy-id',
27
+ "tax-policy-id",
28
28
  {
29
29
  period_start: "2014-09-19T08:18:51.907Z",
30
- period_end: "2014-09-19T08:19:51.907Z"
31
- }
30
+ period_end: "2014-09-19T08:19:51.907Z",
31
+ },
32
32
  )
33
33
 
34
34
  expect(request).to have_been_made
35
35
  end
36
36
 
37
- it 'returns the created rated item' do
38
- client = PactasItero::Client.new(bearer_token: 'bt')
37
+ it "returns the created rated item" do
38
+ client = PactasItero::Client.new(bearer_token: "bt")
39
39
  post_data = {
40
- PeriodStart: '2014-09-19T08:18:51.907Z',
41
- PeriodEnd: '2014-09-19T08:19:51.907Z',
40
+ PeriodStart: "2014-09-19T08:18:51.907Z",
41
+ PeriodEnd: "2014-09-19T08:19:51.907Z",
42
42
  Quantity: 2,
43
- Description: 'the description',
43
+ Description: "the description",
44
44
  PricePerUnit: 123.45,
45
- TaxPolicyId: 'tax-policy-id',
45
+ TaxPolicyId: "tax-policy-id",
46
46
  }.to_json
47
- request = stub_post('/api/v1/contracts/contract-id/ratedItems').
48
- with(body: post_data).
49
- to_return(
50
- body: fixture('create_rated_item.json'),
51
- headers: { content_type: 'application/json; charset=utf-8'}
52
- )
47
+ request = stub_post("/api/v1/contracts/contract-id/ratedItems").
48
+ with(body: post_data).
49
+ to_return(
50
+ body: fixture("create_rated_item.json"),
51
+ headers: { content_type: "application/json; charset=utf-8" },
52
+ )
53
53
 
54
54
  rated_item = client.create_rated_item(
55
- 'contract-id',
55
+ "contract-id",
56
56
  2,
57
- 'the description',
57
+ "the description",
58
58
  123.45,
59
- 'tax-policy-id',
59
+ "tax-policy-id",
60
60
  {
61
61
  period_start: "2014-09-19T08:18:51.907Z",
62
- period_end: "2014-09-19T08:19:51.907Z"
63
- }
62
+ period_end: "2014-09-19T08:19:51.907Z",
63
+ },
64
64
  )
65
65
 
66
- expect(rated_item.description).to eq 'the description'
67
- expect(rated_item.period_end).to eq '2014-09-19T08:18:51.907Z'
68
- expect(rated_item.period_start).to eq '2014-09-19T08:18:51.907Z'
66
+ expect(rated_item.description).to eq "the description"
67
+ expect(rated_item.period_end).to eq "2014-09-19T08:18:51.907Z"
68
+ expect(rated_item.period_start).to eq "2014-09-19T08:18:51.907Z"
69
69
  expect(rated_item.price_per_unit).to eq 123.45
70
70
  expect(rated_item.quantity).to eq 2
71
- expect(rated_item.tax_policy_id).to eq 'tax-policy-id'
71
+ expect(rated_item.tax_policy_id).to eq "tax-policy-id"
72
72
  end
73
73
  end
74
74
 
75
75
  describe ".rated_items" do
76
76
  it "returns rated items" do
77
- client = PactasItero::Client.new(bearer_token: 'bt')
77
+ client = PactasItero::Client.new(bearer_token: "bt")
78
78
  stub_get("/api/v1/contracts/contract-id/ratedItems").
79
79
  to_return(
80
80
  body: fixture("rated_items.json"),
81
- headers: { content_type: "application/json; charset=utf-8"}
81
+ headers: { content_type: "application/json; charset=utf-8" },
82
82
  )
83
83
 
84
84
  rated_items = client.rated_items("contract-id")
@@ -98,11 +98,11 @@ describe PactasItero::Api::RatedItems do
98
98
 
99
99
  describe ".delete_rated_item" do
100
100
  it "deletes a rated item" do
101
- client = PactasItero::Client.new(bearer_token: 'bt')
101
+ client = PactasItero::Client.new(bearer_token: "bt")
102
102
  stub_delete("/api/v1/ratedItems/rated-item-id").
103
103
  to_return(
104
104
  body: "",
105
- headers: { content_type: "application/json; charset=utf-8"}
105
+ headers: { content_type: "application/json; charset=utf-8" },
106
106
  )
107
107
 
108
108
  response = client.delete_rated_item("rated-item-id")