fortnox-api 0.2.0 → 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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +1 -1
  4. data/fortnox-api.gemspec +3 -1
  5. data/lib/fortnox/api/mappers.rb +1 -0
  6. data/lib/fortnox/api/mappers/project.rb +15 -0
  7. data/lib/fortnox/api/models.rb +1 -0
  8. data/lib/fortnox/api/models/base.rb +1 -1
  9. data/lib/fortnox/api/models/customer.rb +0 -0
  10. data/lib/fortnox/api/models/project.rb +40 -0
  11. data/lib/fortnox/api/repositories.rb +1 -0
  12. data/lib/fortnox/api/repositories/base.rb +1 -1
  13. data/lib/fortnox/api/repositories/base/loaders.rb +13 -10
  14. data/lib/fortnox/api/repositories/base/savers.rb +3 -3
  15. data/lib/fortnox/api/repositories/project.rb +15 -0
  16. data/lib/fortnox/api/types.rb +2 -0
  17. data/lib/fortnox/api/types/enums.rb +3 -0
  18. data/lib/fortnox/api/version.rb +1 -1
  19. data/spec/fortnox/api/mappers/project_spec.rb +10 -0
  20. data/spec/fortnox/api/models/customer_spec.rb +1 -3
  21. data/spec/fortnox/api/models/examples/document_base.rb +2 -2
  22. data/spec/fortnox/api/models/examples/model.rb +11 -5
  23. data/spec/fortnox/api/models/invoice_spec.rb +1 -4
  24. data/spec/fortnox/api/models/order_spec.rb +0 -3
  25. data/spec/fortnox/api/models/project_spec.rb +7 -0
  26. data/spec/fortnox/api/repositories/customer_spec.rb +8 -1
  27. data/spec/fortnox/api/repositories/examples/find.rb +65 -10
  28. data/spec/fortnox/api/repositories/examples/search.rb +11 -0
  29. data/spec/fortnox/api/repositories/invoice_spec.rb +11 -1
  30. data/spec/fortnox/api/repositories/order_spec.rb +11 -1
  31. data/spec/fortnox/api/repositories/project_spec.rb +29 -0
  32. data/spec/fortnox/api/types/enums_spec.rb +1 -0
  33. data/spec/vcr_cassettes/customers/find_by_hash_failure.yml +45 -0
  34. data/spec/vcr_cassettes/customers/find_failure.yml +45 -0
  35. data/spec/vcr_cassettes/customers/multi_param_find_by_hash.yml +46 -0
  36. data/spec/vcr_cassettes/customers/search_with_special_char.yml +45 -0
  37. data/spec/vcr_cassettes/customers/single_param_find_by_hash.yml +47 -0
  38. data/spec/vcr_cassettes/invoices/find_by_hash_failure.yml +45 -0
  39. data/spec/vcr_cassettes/invoices/find_failure.yml +45 -0
  40. data/spec/vcr_cassettes/invoices/multi_param_find_by_hash.yml +46 -0
  41. data/spec/vcr_cassettes/invoices/search_with_special_char.yml +45 -0
  42. data/spec/vcr_cassettes/invoices/single_param_find_by_hash.yml +47 -0
  43. data/spec/vcr_cassettes/orders/find_by_hash_failure.yml +45 -0
  44. data/spec/vcr_cassettes/orders/find_failure.yml +45 -0
  45. data/spec/vcr_cassettes/orders/multi_param_find_by_hash.yml +46 -0
  46. data/spec/vcr_cassettes/orders/search_with_special_char.yml +45 -0
  47. data/spec/vcr_cassettes/orders/single_param_find_by_hash.yml +47 -0
  48. data/spec/vcr_cassettes/projects/all.yml +52 -0
  49. data/spec/vcr_cassettes/projects/find_by_hash_failure.yml +45 -0
  50. data/spec/vcr_cassettes/projects/find_failure.yml +45 -0
  51. data/spec/vcr_cassettes/projects/find_id_1.yml +46 -0
  52. data/spec/vcr_cassettes/projects/find_new.yml +46 -0
  53. data/spec/vcr_cassettes/projects/multi_param_find_by_hash.yml +46 -0
  54. data/spec/vcr_cassettes/projects/save_new.yml +45 -0
  55. data/spec/vcr_cassettes/projects/save_old.yml +46 -0
  56. data/spec/vcr_cassettes/projects/single_param_find_by_hash.yml +46 -0
  57. metadata +66 -6
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/invoices/?customername=special%20char%20%C3%A5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Fri, 16 Jun 2017 13:06:57 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '55'
36
+ X-Uid:
37
+ - 77f70371
38
+ X-Build:
39
+ - 2efa532288
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":0,"@TotalPages":0,"@CurrentPage":1},"Invoices":[]}'
43
+ http_version:
44
+ recorded_at: Fri, 16 Jun 2017 13:06:57 GMT
45
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/invoices/?yourreference=Gandalf%20the%20Grey
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 12:24:39 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '36'
36
+ X-Uid:
37
+ - b37dab19
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":2,"@TotalPages":1,"@CurrentPage":1},"Invoices":[{"@url":"https:\/\/api.fortnox.se\/3\/invoices\/2","Balance":0,"Booked":false,"Cancelled":false,"Currency":"SEK","CurrencyRate":"1","CurrencyUnit":1,"CustomerName":"Updated
43
+ customer","CustomerNumber":"1","DocumentNumber":"2","DueDate":"2016-03-18","ExternalInvoiceReference1":"","ExternalInvoiceReference2":"","InvoiceDate":"2016-03-16","NoxFinans":false,"OCR":"232","WayOfDelivery":"","TermsOfPayment":"0","Project":"","Sent":false,"Total":0},{"@url":"https:\/\/api.fortnox.se\/3\/invoices\/3","Balance":200,"Booked":false,"Cancelled":false,"Currency":"SEK","CurrencyRate":"1","CurrencyUnit":1,"CustomerName":"Updated
44
+ customer","CustomerNumber":"1","DocumentNumber":"3","DueDate":"2016-03-17","ExternalInvoiceReference1":"","ExternalInvoiceReference2":"","InvoiceDate":"2016-03-16","NoxFinans":false,"OCR":"331","WayOfDelivery":"","TermsOfPayment":"0","Project":"","Sent":false,"Total":200}]}'
45
+ http_version:
46
+ recorded_at: Wed, 12 Jul 2017 12:24:39 GMT
47
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/orders/?ourreference=Not%20found
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 13:03:37 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '25'
36
+ X-Uid:
37
+ - 95e82329
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":0,"@TotalPages":0,"@CurrentPage":1},"Orders":[]}'
43
+ http_version:
44
+ recorded_at: Wed, 12 Jul 2017 13:03:37 GMT
45
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/orders/123456789
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: Not Found
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 10:21:41 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '22'
36
+ X-Uid:
37
+ - df011e86
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"ErrorInformation":{"Error":1,"Message":"Kan inte hitta ordern.","Code":2000439}}'
43
+ http_version:
44
+ recorded_at: Wed, 12 Jul 2017 10:21:41 GMT
45
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/orders/?ourreference=Belladonna%20Took&yourreference=Bodo%20Proudfoot
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 13:03:27 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '28'
36
+ X-Uid:
37
+ - 700e7e6c
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":1,"@TotalPages":1,"@CurrentPage":1},"Orders":[{"@url":"https:\/\/api.fortnox.se\/3\/orders\/8","Cancelled":false,"Currency":"SEK","CustomerName":"Old
43
+ name","CustomerNumber":"1","DeliveryDate":null,"DocumentNumber":"8","ExternalInvoiceReference1":"","ExternalInvoiceReference2":"","OrderDate":"2016-04-21","Project":"","Sent":false,"Total":0}]}'
44
+ http_version:
45
+ recorded_at: Wed, 12 Jul 2017 13:03:27 GMT
46
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/orders/?customername=special%20char%20%C3%A5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Fri, 16 Jun 2017 13:06:56 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '60'
36
+ X-Uid:
37
+ - bd717ecb
38
+ X-Build:
39
+ - 2efa532288
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":0,"@TotalPages":0,"@CurrentPage":1},"Orders":[]}'
43
+ http_version:
44
+ recorded_at: Fri, 16 Jun 2017 13:06:56 GMT
45
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/orders/?ourreference=Belladonna%20Took
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 13:03:27 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '28'
36
+ X-Uid:
37
+ - '87325977'
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":2,"@TotalPages":1,"@CurrentPage":1},"Orders":[{"@url":"https:\/\/api.fortnox.se\/3\/orders\/8","Cancelled":false,"Currency":"SEK","CustomerName":"Old
43
+ name","CustomerNumber":"1","DeliveryDate":null,"DocumentNumber":"8","ExternalInvoiceReference1":"","ExternalInvoiceReference2":"","OrderDate":"2016-04-21","Project":"","Sent":false,"Total":0},{"@url":"https:\/\/api.fortnox.se\/3\/orders\/9","Cancelled":false,"Currency":"SEK","CustomerName":"Old
44
+ name","CustomerNumber":"1","DeliveryDate":null,"DocumentNumber":"9","ExternalInvoiceReference1":"","ExternalInvoiceReference2":"","OrderDate":"2016-04-21","Project":"","Sent":false,"Total":0}]}'
45
+ http_version:
46
+ recorded_at: Wed, 12 Jul 2017 13:03:27 GMT
47
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/projects/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 19:13:42 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '13'
36
+ X-Uid:
37
+ - bcdb41d9
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":8,"@TotalPages":1,"@CurrentPage":1},"Projects":[{"@url":"https:\/\/api.fortnox.se\/3\/projects\/1","Description":"Test
43
+ project","EndDate":null,"ProjectNumber":"1","Status":"ONGOING","StartDate":"2016-05-02"},{"@url":"https:\/\/api.fortnox.se\/3\/projects\/17","Description":"Benjamin
44
+ Andersson","EndDate":null,"ProjectNumber":"17","Status":"ONGOING","StartDate":"2017-06-16"},{"@url":"https:\/\/api.fortnox.se\/3\/projects\/18","Description":"Andrea
45
+ Johansson","EndDate":null,"ProjectNumber":"18","Status":"ONGOING","StartDate":"2017-06-16"},{"@url":"https:\/\/api.fortnox.se\/3\/projects\/2","Description":"BolagsKraft","EndDate":null,"ProjectNumber":"2","Status":"ONGOING","StartDate":"2016-05-13"},{"@url":"https:\/\/api.fortnox.se\/3\/projects\/3","Description":"AK
46
+ Bolagskraft","EndDate":null,"ProjectNumber":"3","Status":"ONGOING","StartDate":"2016-09-01"},{"@url":"https:\/\/api.fortnox.se\/3\/projects\/5568","Description":"Thom
47
+ Andersson","EndDate":null,"ProjectNumber":"5568","Status":"ONGOING","StartDate":"2016-12-28"},{"@url":"https:\/\/api.fortnox.se\/3\/projects\/5569","Description":"Nji
48
+ Nij","EndDate":null,"ProjectNumber":"5569","Status":"ONGOING","StartDate":"2017-05-18"},{"@url":"https:\/\/api.fortnox.se\/3\/projects\/5570","Description":"Some
49
+ important project","EndDate":null,"ProjectNumber":"5570","Status":"ONGOING","StartDate":null}]}'
50
+ http_version:
51
+ recorded_at: Wed, 12 Jul 2017 19:13:42 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/projects/?offset=10000
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 19:16:59 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '16'
36
+ X-Uid:
37
+ - d56ef1b1
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"MetaInformation":{"@TotalResources":0,"@TotalPages":0,"@CurrentPage":1},"Projects":[]}'
43
+ http_version:
44
+ recorded_at: Wed, 12 Jul 2017 19:16:59 GMT
45
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.fortnox.se/3/projects/123456789
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ Client-Secret:
15
+ - 9aBA8ZgsvR
16
+ Access-Token:
17
+ - ccaef817-d5d8-4b1c-a316-54f3e55c5c54
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: Not Found
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Wed, 12 Jul 2017 19:16:13 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ - Accept-Encoding
34
+ X-Rack-Responsetime:
35
+ - '13'
36
+ X-Uid:
37
+ - 4790a5fa
38
+ X-Build:
39
+ - 401ff9d5e0
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"ErrorInformation":{"Error":1,"Message":"Kan inte hitta projektet.","Code":2001161}}'
43
+ http_version:
44
+ recorded_at: Wed, 12 Jul 2017 19:16:13 GMT
45
+ recorded_with: VCR 3.0.3