tripletexer 0.1.2 → 0.2.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -1
  3. data/lib/tripletexer.rb +23 -28
  4. data/lib/tripletexer/api_client.rb +95 -0
  5. data/lib/tripletexer/endpoints/abstract_endpoint.rb +12 -62
  6. data/lib/tripletexer/endpoints/customer.rb +1 -1
  7. data/lib/tripletexer/endpoints/employee.rb +1 -1
  8. data/lib/tripletexer/endpoints/invoice.rb +4 -4
  9. data/lib/tripletexer/endpoints/ledger.rb +10 -10
  10. data/lib/tripletexer/endpoints/ledger/close_group.rb +2 -2
  11. data/lib/tripletexer/endpoints/ledger/posting.rb +2 -2
  12. data/lib/tripletexer/endpoints/ledger/voucher.rb +2 -2
  13. data/lib/tripletexer/endpoints/order.rb +5 -5
  14. data/lib/tripletexer/endpoints/project.rb +1 -1
  15. data/lib/tripletexer/endpoints/timesheet.rb +2 -2
  16. data/lib/tripletexer/endpoints/timesheet/entry.rb +2 -2
  17. data/lib/tripletexer/endpoints/timesheet/time_clock.rb +2 -2
  18. data/lib/tripletexer/endpoints/token.rb +2 -2
  19. data/lib/tripletexer/endpoints/token/session.rb +7 -7
  20. data/lib/tripletexer/format_helpers.rb +8 -5
  21. data/lib/tripletexer/version.rb +1 -1
  22. data/spec/client_spec.rb +56 -0
  23. data/spec/endpoints/order_spec.rb +50 -0
  24. data/spec/endpoints/timesheet_spec.rb +19 -0
  25. data/spec/endpoints/token/session_spec.rb +33 -0
  26. data/spec/endpoints/token_spec.rb +19 -0
  27. data/spec/format_helpers_spec.rb +55 -0
  28. data/spec/spec_helper.rb +111 -0
  29. data/spec/tripletexer_spec.rb +114 -0
  30. data/spec/vcr_cassettes/endpoints/order/find.yml +116 -0
  31. data/spec/vcr_cassettes/endpoints/order/find__unauthorized.yml +71 -0
  32. data/spec/vcr_cassettes/endpoints/order/search.yml +164 -0
  33. data/spec/vcr_cassettes/endpoints/token/session/create.yml +77 -0
  34. data/spec/vcr_cassettes/endpoints/token/session/destroy.yml +295 -0
  35. data/spec/vcr_cassettes/endpoints/token/session/whoami.yml +68 -0
  36. data/spec/web_helper.rb +20 -0
  37. metadata +162 -16
  38. data/lib/tripletexer/connection.rb +0 -49
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Tripletexer do
6
+ describe '#activity' do
7
+ it 'returns Activity endpoint' do
8
+ expect( subject.activity ).to be_an_instance_of Tripletexer::Endpoints::Activity
9
+ end
10
+ end
11
+
12
+ describe "#address" do
13
+ it 'returns address endpoint' do
14
+ expect( subject.address ).to be_an_instance_of Tripletexer::Endpoints::Address
15
+ end
16
+ end
17
+
18
+ describe "#company" do
19
+ it 'returns company endpoint' do
20
+ expect( subject.company ).to be_an_instance_of Tripletexer::Endpoints::Company
21
+ end
22
+ end
23
+
24
+ describe "#contact" do
25
+ it 'returns contact endpoint' do
26
+ expect( subject.contact ).to be_an_instance_of Tripletexer::Endpoints::Contact
27
+ end
28
+ end
29
+
30
+ describe "#country" do
31
+ it 'returns country endpoint' do
32
+ expect( subject.country ).to be_an_instance_of Tripletexer::Endpoints::Country
33
+ end
34
+ end
35
+
36
+ describe "#currency" do
37
+ it 'returns currency endpoint' do
38
+ expect( subject.currency ).to be_an_instance_of Tripletexer::Endpoints::Currency
39
+ end
40
+ end
41
+
42
+ describe "#customer" do
43
+ it 'returns customer endpoint' do
44
+ expect( subject.customer ).to be_an_instance_of Tripletexer::Endpoints::Customer
45
+ end
46
+ end
47
+
48
+ describe "#department" do
49
+ it 'returns department endpoint' do
50
+ expect( subject.department ).to be_an_instance_of Tripletexer::Endpoints::Department
51
+ end
52
+ end
53
+
54
+ describe "#employee" do
55
+ it 'returns employee endpoint' do
56
+ expect( subject.employee ).to be_an_instance_of Tripletexer::Endpoints::Employee
57
+ end
58
+ end
59
+
60
+ describe "#inventory" do
61
+ it 'returns inventory endpoint' do
62
+ expect( subject.inventory ).to be_an_instance_of Tripletexer::Endpoints::Inventory
63
+ end
64
+ end
65
+
66
+ describe "#invoice" do
67
+ it 'returns invoice endpoint' do
68
+ expect( subject.invoice ).to be_an_instance_of Tripletexer::Endpoints::Invoice
69
+ end
70
+ end
71
+
72
+ describe "#ledger" do
73
+ it 'returns ledger endpoint' do
74
+ expect( subject.ledger ).to be_an_instance_of Tripletexer::Endpoints::Ledger
75
+ end
76
+ end
77
+
78
+ describe "#order" do
79
+ it 'returns order endpoint' do
80
+ expect( subject.order ).to be_an_instance_of Tripletexer::Endpoints::Order
81
+ end
82
+ end
83
+
84
+ describe "#product" do
85
+ it 'returns product endpoint' do
86
+ expect( subject.product ).to be_an_instance_of Tripletexer::Endpoints::Product
87
+ end
88
+ end
89
+
90
+ describe "#project" do
91
+ it 'returns project endpoint' do
92
+ expect( subject.project ).to be_an_instance_of Tripletexer::Endpoints::Project
93
+ end
94
+ end
95
+
96
+ describe "#supplier" do
97
+ it 'returns supplier endpoint' do
98
+ expect( subject.supplier ).to be_an_instance_of Tripletexer::Endpoints::Supplier
99
+ end
100
+ end
101
+
102
+ describe "#timesheet" do
103
+ it 'returns timesheet endpoint' do
104
+ expect( subject.timesheet ).to be_an_instance_of Tripletexer::Endpoints::Timesheet
105
+ end
106
+ end
107
+
108
+ describe "#token" do
109
+ it 'returns token endpoint' do
110
+ expect( subject.token ).to be_an_instance_of Tripletexer::Endpoints::Token
111
+ end
112
+ end
113
+
114
+ end
@@ -0,0 +1,116 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://tripletex.no/v2/order/23432678
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Authorization:
13
+ - Basic MDpiNWM3ODNkMC01YjBhLTRiZjItODEyNi1mNGNmYWE4ZWE2ZWE=
14
+ User-Agent:
15
+ - Faraday v0.10.0
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ Frame-Options:
28
+ - SAMEORIGIN
29
+ Strict-Transport-Security:
30
+ - max-age=31536000
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Cache-Control:
36
+ - no-store, no-cache, must-revalidate, max-age=0
37
+ - post-check=0, pre-check=0
38
+ Pragma:
39
+ - no-cache
40
+ Set-Cookie:
41
+ - JSESSIONID=D9876D62E65D40061F4AA940D9B40D16; Domain=tripletex.no; Path=/;
42
+ Secure; HttpOnly
43
+ X-Rate-Limit-Limit:
44
+ - '100'
45
+ X-Rate-Limit-Remaining:
46
+ - '99'
47
+ X-Rate-Limit-Reset:
48
+ - '4'
49
+ Content-Type:
50
+ - application/json;charset=UTF-8
51
+ Content-Length:
52
+ - '1530'
53
+ Date:
54
+ - Wed, 27 Sep 2017 19:11:25 GMT
55
+ Server:
56
+ - tripletex.no
57
+ body:
58
+ encoding: UTF-8
59
+ string: |-
60
+ {
61
+ "value" : {
62
+ "id" : 23432678,
63
+ "version" : 0,
64
+ "url" : "tripletex.no/v2/order/23432678",
65
+ "customer" : {
66
+ "id" : 6221272,
67
+ "url" : "tripletex.no/v2/customer/6221272"
68
+ },
69
+ "contact" : null,
70
+ "attn" : null,
71
+ "receiverEmail" : "",
72
+ "overdueNoticeEmail" : "",
73
+ "number" : "1",
74
+ "reference" : "",
75
+ "ourContactEmployee" : {
76
+ "id" : 1158417,
77
+ "url" : "tripletex.no/v2/employee/1158417"
78
+ },
79
+ "department" : null,
80
+ "orderDate" : "2017-09-13",
81
+ "project" : null,
82
+ "invoiceComment" : "",
83
+ "currency" : {
84
+ "id" : 1,
85
+ "url" : "tripletex.no/v2/currency/1"
86
+ },
87
+ "invoicesDueIn" : 14,
88
+ "invoicesDueInType" : "DAYS",
89
+ "isShowOpenPostsOnInvoices" : false,
90
+ "isClosed" : false,
91
+ "deliveryDate" : "2017-09-13",
92
+ "deliveryAddress" : null,
93
+ "deliveryComment" : "",
94
+ "isPrioritizeAmountsIncludingVat" : false,
95
+ "orderLineSorting" : "PRODUCT",
96
+ "orderLines" : [ {
97
+ "id" : 41516052,
98
+ "url" : "tripletex.no/v2/order/orderline/41516052"
99
+ }, {
100
+ "id" : 41516053,
101
+ "url" : "tripletex.no/v2/order/orderline/41516053"
102
+ } ],
103
+ "isSubscription" : false,
104
+ "subscriptionDuration" : 1,
105
+ "subscriptionDurationType" : "MONTHS",
106
+ "subscriptionPeriodsOnInvoice" : 1,
107
+ "subscriptionPeriodsOnInvoiceType" : "MONTHS",
108
+ "subscriptionInvoicingTimeInAdvanceOrArrears" : "ADVANCE",
109
+ "subscriptionInvoicingTime" : 0,
110
+ "subscriptionInvoicingTimeType" : "MONTHS",
111
+ "isSubscriptionAutoInvoicing" : false
112
+ }
113
+ }
114
+ http_version:
115
+ recorded_at: Wed, 27 Sep 2017 19:11:25 GMT
116
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://tripletex.no/v2/order/23432677
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Authorization:
13
+ - Basic MDpiNWM3ODNkMC01YjBhLTRiZjItODEyNi1mNGNmYWE4ZWE2ZWE=
14
+ User-Agent:
15
+ - Faraday v0.10.0
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ Frame-Options:
28
+ - SAMEORIGIN
29
+ Strict-Transport-Security:
30
+ - max-age=31536000
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Cache-Control:
36
+ - no-store, no-cache, must-revalidate, max-age=0
37
+ - post-check=0, pre-check=0
38
+ Pragma:
39
+ - no-cache
40
+ Set-Cookie:
41
+ - JSESSIONID=4EDB6A5AC11F1EE742B1E259A511D681; Domain=tripletex.no; Path=/;
42
+ Secure; HttpOnly
43
+ X-Rate-Limit-Limit:
44
+ - '100'
45
+ X-Rate-Limit-Remaining:
46
+ - '99'
47
+ X-Rate-Limit-Reset:
48
+ - '3'
49
+ Content-Type:
50
+ - application/json;charset=UTF-8
51
+ Content-Length:
52
+ - '224'
53
+ Date:
54
+ - Wed, 27 Sep 2017 19:13:56 GMT
55
+ Server:
56
+ - tripletex.no
57
+ body:
58
+ encoding: UTF-8
59
+ string: |-
60
+ {
61
+ "status" : 401,
62
+ "code" : 9000,
63
+ "message" : "Attempt to read unauthorized object.",
64
+ "link" : null,
65
+ "developerMessage" : null,
66
+ "validationMessages" : null,
67
+ "requestId" : "9a34b97c-f32d-451e-84a7-253ee809e8bf"
68
+ }
69
+ http_version:
70
+ recorded_at: Wed, 27 Sep 2017 19:13:57 GMT
71
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,164 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://tripletex.no/v2/order?orderDateFrom=2017-01-01&orderDateTo=2018-09-26
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Authorization:
13
+ - Basic MDpiNWM3ODNkMC01YjBhLTRiZjItODEyNi1mNGNmYWE4ZWE2ZWE=
14
+ User-Agent:
15
+ - Faraday v0.10.0
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ Frame-Options:
28
+ - SAMEORIGIN
29
+ Strict-Transport-Security:
30
+ - max-age=31536000
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Cache-Control:
36
+ - no-store, no-cache, must-revalidate, max-age=0
37
+ - post-check=0, pre-check=0
38
+ Pragma:
39
+ - no-cache
40
+ Set-Cookie:
41
+ - JSESSIONID=87A9BF3D53CB7B1894374290B27B7A1F; Domain=tripletex.no; Path=/;
42
+ Secure; HttpOnly
43
+ X-Rate-Limit-Limit:
44
+ - '100'
45
+ X-Rate-Limit-Remaining:
46
+ - '99'
47
+ X-Rate-Limit-Reset:
48
+ - '7'
49
+ Content-Type:
50
+ - application/json;charset=UTF-8
51
+ Content-Length:
52
+ - '2935'
53
+ Date:
54
+ - Wed, 27 Sep 2017 19:06:22 GMT
55
+ Server:
56
+ - tripletex.no
57
+ body:
58
+ encoding: UTF-8
59
+ string: |-
60
+ {
61
+ "fullResultSize" : 2,
62
+ "from" : 0,
63
+ "count" : 2,
64
+ "versionDigest" : "txtemTgnGbSFk0NynqxAMA==",
65
+ "values" : [ {
66
+ "id" : 23432678,
67
+ "version" : 0,
68
+ "url" : "tripletex.no/v2/order/23432678",
69
+ "customer" : {
70
+ "id" : 6221272,
71
+ "url" : "tripletex.no/v2/customer/6221272"
72
+ },
73
+ "contact" : null,
74
+ "attn" : null,
75
+ "receiverEmail" : "",
76
+ "overdueNoticeEmail" : "",
77
+ "number" : "1",
78
+ "reference" : "",
79
+ "ourContactEmployee" : {
80
+ "id" : 1158417,
81
+ "url" : "tripletex.no/v2/employee/1158417"
82
+ },
83
+ "department" : null,
84
+ "orderDate" : "2017-09-13",
85
+ "project" : null,
86
+ "invoiceComment" : "",
87
+ "currency" : {
88
+ "id" : 1,
89
+ "url" : "tripletex.no/v2/currency/1"
90
+ },
91
+ "invoicesDueIn" : 14,
92
+ "invoicesDueInType" : "DAYS",
93
+ "isShowOpenPostsOnInvoices" : false,
94
+ "isClosed" : false,
95
+ "deliveryDate" : "2017-09-13",
96
+ "deliveryAddress" : null,
97
+ "deliveryComment" : "",
98
+ "isPrioritizeAmountsIncludingVat" : false,
99
+ "orderLineSorting" : "PRODUCT",
100
+ "orderLines" : [ {
101
+ "id" : 41516052,
102
+ "url" : "tripletex.no/v2/order/orderline/41516052"
103
+ }, {
104
+ "id" : 41516053,
105
+ "url" : "tripletex.no/v2/order/orderline/41516053"
106
+ } ],
107
+ "isSubscription" : false,
108
+ "subscriptionDuration" : 1,
109
+ "subscriptionDurationType" : "MONTHS",
110
+ "subscriptionPeriodsOnInvoice" : 1,
111
+ "subscriptionPeriodsOnInvoiceType" : "MONTHS",
112
+ "subscriptionInvoicingTimeInAdvanceOrArrears" : "ADVANCE",
113
+ "subscriptionInvoicingTime" : 0,
114
+ "subscriptionInvoicingTimeType" : "MONTHS",
115
+ "isSubscriptionAutoInvoicing" : false
116
+ }, {
117
+ "id" : 23767271,
118
+ "version" : 0,
119
+ "url" : "tripletex.no/v2/order/23767271",
120
+ "customer" : {
121
+ "id" : 6299534,
122
+ "url" : "tripletex.no/v2/customer/6299534"
123
+ },
124
+ "contact" : null,
125
+ "attn" : null,
126
+ "receiverEmail" : "",
127
+ "overdueNoticeEmail" : "",
128
+ "number" : "2",
129
+ "reference" : "",
130
+ "department" : {
131
+ "id" : 56029,
132
+ "url" : "tripletex.no/v2/department/56029"
133
+ },
134
+ "orderDate" : "2017-08-18",
135
+ "project" : null,
136
+ "invoiceComment" : "",
137
+ "currency" : {
138
+ "id" : 1,
139
+ "url" : "tripletex.no/v2/currency/1"
140
+ },
141
+ "invoicesDueIn" : 10,
142
+ "invoicesDueInType" : "DAYS",
143
+ "isShowOpenPostsOnInvoices" : false,
144
+ "isClosed" : false,
145
+ "deliveryDate" : "2017-09-25",
146
+ "deliveryAddress" : null,
147
+ "deliveryComment" : "",
148
+ "isPrioritizeAmountsIncludingVat" : false,
149
+ "orderLineSorting" : "ID",
150
+ "orderLines" : [ ],
151
+ "isSubscription" : false,
152
+ "subscriptionDuration" : 0,
153
+ "subscriptionDurationType" : "MONTHS",
154
+ "subscriptionPeriodsOnInvoice" : 0,
155
+ "subscriptionPeriodsOnInvoiceType" : "MONTHS",
156
+ "subscriptionInvoicingTimeInAdvanceOrArrears" : "ADVANCE",
157
+ "subscriptionInvoicingTime" : 0,
158
+ "subscriptionInvoicingTimeType" : "MONTHS",
159
+ "isSubscriptionAutoInvoicing" : false
160
+ } ]
161
+ }
162
+ http_version:
163
+ recorded_at: Wed, 27 Sep 2017 19:06:22 GMT
164
+ recorded_with: VCR 3.0.3