fakturoid 0.5.0 → 1.1.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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -10
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +15 -0
  5. data/README.md +540 -145
  6. data/Rakefile +3 -1
  7. data/fakturoid.gemspec +36 -25
  8. data/lib/fakturoid/api/account.rb +13 -0
  9. data/lib/fakturoid/api/bank_account.rb +13 -0
  10. data/lib/fakturoid/api/base.rb +18 -0
  11. data/lib/fakturoid/api/event.rb +23 -0
  12. data/lib/fakturoid/api/expense.rb +55 -0
  13. data/lib/fakturoid/api/expense_payment.rb +20 -0
  14. data/lib/fakturoid/api/generator.rb +36 -0
  15. data/lib/fakturoid/api/inbox_file.rb +34 -0
  16. data/lib/fakturoid/api/inventory_item.rb +66 -0
  17. data/lib/fakturoid/api/inventory_move.rb +40 -0
  18. data/lib/fakturoid/api/invoice.rb +62 -0
  19. data/lib/fakturoid/api/invoice_message.rb +14 -0
  20. data/lib/fakturoid/api/invoice_payment.rb +26 -0
  21. data/lib/fakturoid/api/number_format.rb +13 -0
  22. data/lib/fakturoid/api/recurring_generator.rb +36 -0
  23. data/lib/fakturoid/api/subject.rb +42 -0
  24. data/lib/fakturoid/api/todo.rb +20 -0
  25. data/lib/fakturoid/api/user.rb +17 -0
  26. data/lib/fakturoid/api/webhook.rb +34 -0
  27. data/lib/fakturoid/api.rb +89 -9
  28. data/lib/fakturoid/client.rb +46 -12
  29. data/lib/fakturoid/config.rb +69 -12
  30. data/lib/fakturoid/oauth/access_token_service.rb +46 -0
  31. data/lib/fakturoid/oauth/credentials.rb +63 -0
  32. data/lib/fakturoid/oauth/flow/authorization_code.rb +53 -0
  33. data/lib/fakturoid/oauth/flow/base.rb +42 -0
  34. data/lib/fakturoid/oauth/flow/client_credentials.rb +27 -0
  35. data/lib/fakturoid/oauth/flow.rb +5 -0
  36. data/lib/fakturoid/oauth/request/api.rb +11 -0
  37. data/lib/fakturoid/oauth/request/base.rb +60 -0
  38. data/lib/fakturoid/oauth/request/oauth.rb +24 -0
  39. data/lib/fakturoid/oauth/request.rb +5 -0
  40. data/lib/fakturoid/oauth/token_response.rb +56 -0
  41. data/lib/fakturoid/oauth.rb +39 -0
  42. data/lib/fakturoid/response.rb +8 -20
  43. data/lib/fakturoid/utils.rb +27 -0
  44. data/lib/fakturoid/version.rb +1 -1
  45. data/lib/fakturoid.rb +22 -22
  46. metadata +48 -53
  47. data/.github/workflows/rubocop.yml +0 -20
  48. data/.github/workflows/tests.yml +0 -27
  49. data/.gitignore +0 -7
  50. data/Gemfile +0 -6
  51. data/lib/fakturoid/api/arguments.rb +0 -21
  52. data/lib/fakturoid/api/http_methods.rb +0 -23
  53. data/lib/fakturoid/client/account.rb +0 -11
  54. data/lib/fakturoid/client/bank_account.rb +0 -11
  55. data/lib/fakturoid/client/event.rb +0 -19
  56. data/lib/fakturoid/client/expense.rb +0 -49
  57. data/lib/fakturoid/client/generator.rb +0 -44
  58. data/lib/fakturoid/client/inventory_items.rb +0 -59
  59. data/lib/fakturoid/client/inventory_moves.rb +0 -36
  60. data/lib/fakturoid/client/invoice.rb +0 -73
  61. data/lib/fakturoid/client/number_format.rb +0 -11
  62. data/lib/fakturoid/client/subject.rb +0 -41
  63. data/lib/fakturoid/client/todo.rb +0 -18
  64. data/lib/fakturoid/client/user.rb +0 -20
  65. data/lib/fakturoid/connection.rb +0 -30
  66. data/lib/fakturoid/request.rb +0 -31
  67. data/test/api_test.rb +0 -24
  68. data/test/config_test.rb +0 -40
  69. data/test/fixtures/blocked_account.json +0 -8
  70. data/test/fixtures/invoice.json +0 -81
  71. data/test/fixtures/invoice.pdf +0 -0
  72. data/test/fixtures/invoice_error.json +0 -7
  73. data/test/fixtures/subjects.json +0 -52
  74. data/test/request_test.rb +0 -20
  75. data/test/response_test.rb +0 -189
  76. data/test/test_helper.rb +0 -19
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Generator < Fakturoid::Api
6
- def self.all(params = {})
7
- request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
8
-
9
- get_request("generators.json", request_params: request_params)
10
- end
11
-
12
- def self.recurring(params = {})
13
- request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
14
-
15
- get_request("generators/recurring.json", request_params: request_params)
16
- end
17
-
18
- def self.template(params = {})
19
- request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
20
-
21
- get_request("generators/template.json", request_params: request_params)
22
- end
23
-
24
- def self.find(id)
25
- validate_numerical_id(id)
26
- get_request("generators/#{id}.json")
27
- end
28
-
29
- def self.create(payload = {})
30
- post_request("generators.json", payload: payload)
31
- end
32
-
33
- def self.update(id, payload = {})
34
- validate_numerical_id(id)
35
- patch_request("generators/#{id}.json", payload: payload)
36
- end
37
-
38
- def self.delete(id)
39
- validate_numerical_id(id)
40
- delete_request("generators/#{id}.json")
41
- end
42
- end
43
- end
44
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class InventoryItems < Fakturoid::Api
6
- INDEX_PARAMS = [:page, :since, :updated_since, :article_number, :sku].freeze
7
-
8
- def self.all(params = {})
9
- request_params = permit_params(params, *INDEX_PARAMS) || {}
10
-
11
- get_request("inventory_items.json", request_params: request_params)
12
- end
13
-
14
- def self.archived(params = {})
15
- request_params = permit_params(params, *INDEX_PARAMS) || {}
16
-
17
- get_request("inventory_items/archived.json", request_params: request_params)
18
- end
19
-
20
- def self.find(id)
21
- validate_numerical_id(id)
22
- get_request("inventory_items/#{id}.json")
23
- end
24
-
25
- def self.search(query, params = {})
26
- validate_search_query(query)
27
-
28
- request_params = permit_params(params, :page)
29
- request_params[:query] = query
30
-
31
- get_request("inventory_items/search.json", request_params: request_params)
32
- end
33
-
34
- def self.archive(id)
35
- validate_numerical_id(id)
36
- post_request("inventory_items/#{id}/archive.json")
37
- end
38
-
39
- def self.unarchive(id)
40
- validate_numerical_id(id)
41
- post_request("inventory_items/#{id}/unarchive.json")
42
- end
43
-
44
- def self.create(payload = {})
45
- post_request("inventory_items.json", payload: payload)
46
- end
47
-
48
- def self.update(id, payload = {})
49
- validate_numerical_id(id)
50
- patch_request("inventory_items/#{id}.json", payload: payload)
51
- end
52
-
53
- def self.delete(id)
54
- validate_numerical_id(id)
55
- delete_request("inventory_items/#{id}.json")
56
- end
57
- end
58
- end
59
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class InventoryMoves < Fakturoid::Api
6
- def self.all(params = {})
7
- request_params = permit_params(params, :page, :since, :updated_since, :inventory_item_id) || {}
8
-
9
- get_request("inventory_moves.json", request_params: request_params)
10
- end
11
-
12
- def self.find(inventory_item_id, id)
13
- validate_numerical_id(inventory_item_id)
14
- validate_numerical_id(id)
15
- get_request("inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json")
16
- end
17
-
18
- def self.create(inventory_item_id, payload = {})
19
- validate_numerical_id(inventory_item_id)
20
- post_request("inventory_items/#{inventory_item_id}/inventory_moves.json", payload: payload)
21
- end
22
-
23
- def self.update(inventory_item_id, id, payload = {})
24
- validate_numerical_id(inventory_item_id)
25
- validate_numerical_id(id)
26
- patch_request("inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json", payload: payload)
27
- end
28
-
29
- def self.delete(inventory_item_id, id)
30
- validate_numerical_id(inventory_item_id)
31
- validate_numerical_id(id)
32
- delete_request("inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json")
33
- end
34
- end
35
- end
36
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Invoice < Fakturoid::Api
6
- INDEX_PARAMS = [:page, :since, :until, :updated_since, :updated_until, :number, :status, :subject_id, :custom_id].freeze
7
-
8
- def self.all(params = {})
9
- request_params = permit_params(params, *INDEX_PARAMS) || {}
10
-
11
- get_request("invoices.json", request_params: request_params)
12
- end
13
-
14
- def self.regular(params = {})
15
- request_params = permit_params(params, *INDEX_PARAMS) || {}
16
-
17
- get_request("invoices/regular.json", request_params: request_params)
18
- end
19
-
20
- def self.proforma(params = {})
21
- request_params = permit_params(params, *INDEX_PARAMS) || {}
22
-
23
- get_request("invoices/proforma.json", request_params: request_params)
24
- end
25
-
26
- def self.find(id)
27
- validate_numerical_id(id)
28
- get_request("invoices/#{id}.json")
29
- end
30
-
31
- def self.search(query, params = {})
32
- validate_search_query(query)
33
-
34
- request_params = permit_params(params, :page)
35
- request_params[:query] = query
36
-
37
- get_request("invoices/search.json", request_params: request_params)
38
- end
39
-
40
- def self.download_pdf(id)
41
- validate_numerical_id(id)
42
- get_request("invoices/#{id}/download.pdf", headers: { content_type: "application/pdf" })
43
- end
44
-
45
- def self.fire(id, event, params = {})
46
- request_params = permit_params(params, :paid_at, :paid_amount, :variable_symbol, :bank_account_id) || {}
47
- request_params[:event] = event
48
-
49
- validate_numerical_id(id)
50
- post_request("invoices/#{id}/fire.json", request_params: request_params)
51
- end
52
-
53
- def self.deliver_message(invoice_id, payload = {})
54
- validate_numerical_id(invoice_id)
55
- post_request("invoices/#{invoice_id}/message.json", payload: payload)
56
- end
57
-
58
- def self.create(payload = {})
59
- post_request("invoices.json", payload: payload)
60
- end
61
-
62
- def self.update(id, payload = {})
63
- validate_numerical_id(id)
64
- patch_request("invoices/#{id}.json", payload: payload)
65
- end
66
-
67
- def self.delete(id)
68
- validate_numerical_id(id)
69
- delete_request("invoices/#{id}.json")
70
- end
71
- end
72
- end
73
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class NumberFormat < Fakturoid::Api
6
- def self.invoices
7
- get_request("number_formats/invoices.json")
8
- end
9
- end
10
- end
11
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Subject < Fakturoid::Api
6
- def self.all(params = {})
7
- request_params = permit_params(params, :page, :since, :updated_since, :custom_id) || {}
8
-
9
- get_request("subjects.json", request_params: request_params)
10
- end
11
-
12
- def self.find(id)
13
- validate_numerical_id(id)
14
- get_request("subjects/#{id}.json")
15
- end
16
-
17
- def self.search(query, params = {})
18
- validate_search_query(query)
19
-
20
- request_params = permit_params(params, :page)
21
- request_params[:query] = query
22
-
23
- get_request("subjects/search.json", request_params: request_params)
24
- end
25
-
26
- def self.create(payload = {})
27
- post_request("subjects.json", payload: payload)
28
- end
29
-
30
- def self.update(id, payload = {})
31
- validate_numerical_id(id)
32
- patch_request("subjects/#{id}.json", payload: payload)
33
- end
34
-
35
- def self.delete(id)
36
- validate_numerical_id(id)
37
- delete_request("subjects/#{id}.json")
38
- end
39
- end
40
- end
41
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Todo < Fakturoid::Api
6
- def self.all(params = {})
7
- request_params = permit_params(params, :page, :since) || {}
8
-
9
- get_request("todos.json", request_params: request_params)
10
- end
11
-
12
- def self.toggle_completion(id)
13
- validate_numerical_id(id)
14
- post_request("todos/#{id}/toggle_completion.json")
15
- end
16
- end
17
- end
18
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class User < Api
6
- def self.current
7
- get_request("user.json", url: Fakturoid::Api.config.endpoint_without_account)
8
- end
9
-
10
- def self.find(id)
11
- validate_numerical_id(id)
12
- get_request("users/#{id}.json")
13
- end
14
-
15
- def self.all
16
- get_request("users.json")
17
- end
18
- end
19
- end
20
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Connection
5
- DEFAULT_CONTENT_TYPE = "application/json"
6
-
7
- def default_options(options = {})
8
- {
9
- headers: {
10
- content_type: options.dig(:headers, :content_type) || DEFAULT_CONTENT_TYPE,
11
- user_agent: Fakturoid::Api.config.user_agent
12
- },
13
- url: options[:url] || Fakturoid::Api.config.endpoint
14
- }
15
- end
16
-
17
- def connection(options = {})
18
- @connection = Faraday.new default_options(options)
19
-
20
- # https://lostisland.github.io/faraday/middleware/authentication
21
- if Fakturoid::Api.config.faraday_v1?
22
- @connection.request :basic_auth, Fakturoid::Api.config.email, Fakturoid::Api.config.api_key
23
- else
24
- @connection.request :authorization, :basic, Fakturoid::Api.config.email, Fakturoid::Api.config.api_key
25
- end
26
-
27
- @connection
28
- end
29
- end
30
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- class Request
5
- include Connection
6
-
7
- attr_reader :method, :path, :caller
8
-
9
- HTTP_METHODS = [:get, :post, :patch, :delete].freeze
10
-
11
- def initialize(method, path, caller)
12
- @method = method
13
- @path = path
14
- @caller = caller
15
- end
16
-
17
- def call(params = {})
18
- raise ArgumentError, "Unknown http method: #{method}" unless HTTP_METHODS.include?(method.to_sym)
19
-
20
- request_params = params[:request_params] || {}
21
-
22
- http_connection = connection(params)
23
- response = http_connection.send(method) do |req|
24
- req.url path, request_params
25
- req.headers["X-Client-Env"] = "Ruby #{RUBY_VERSION}"
26
- req.body = MultiJson.dump(params[:payload]) if params.key?(:payload)
27
- end
28
- Response.new(response, caller, method)
29
- end
30
- end
31
- end
data/test/api_test.rb DELETED
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- class Fakturoid::ApiTest < Fakturoid::TestCase
6
- should "permit only required arguments" do
7
- hash = { page: 4, number: "2015-0015", account: 15 }
8
- permitted_params = Fakturoid::Api.permit_params(hash, :page, :number, :status)
9
- assert_equal({ page: 4, number: "2015-0015" }, permitted_params)
10
- end
11
-
12
- should "raise argument error if id is in wrong format" do
13
- assert_raises(ArgumentError) { Fakturoid::Api.validate_numerical_id(nil) }
14
- assert_raises(ArgumentError) { Fakturoid::Api.validate_numerical_id("nil") }
15
- assert Fakturoid::Api.validate_numerical_id(15)
16
- assert Fakturoid::Api.validate_numerical_id("15")
17
- end
18
-
19
- should "raise argument error if search query is not given" do
20
- assert_raises(ArgumentError) { Fakturoid::Api.validate_search_query(nil) }
21
- assert_raises(ArgumentError) { Fakturoid::Api.validate_search_query("") }
22
- assert Fakturoid::Api.validate_search_query("Company name")
23
- end
24
- end
data/test/config_test.rb DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- class Fakturoid::ConfigTest < Fakturoid::TestCase
6
- should "configure with block param" do
7
- config = Fakturoid::Config.new do |c|
8
- c.email = "test@email.cz"
9
- c.api_key = "XXXXXXXXXXX"
10
- c.account = "testaccount"
11
- c.user_agent = "My test app (test@email.cz)"
12
- end
13
-
14
- assert_equal "test@email.cz", config.email
15
- assert_equal "XXXXXXXXXXX", config.api_key
16
- assert_equal "testaccount", config.account
17
- assert_equal "My test app (test@email.cz)", config.user_agent
18
- end
19
-
20
- should "use default user agent" do
21
- config = Fakturoid::Config.new do |c|
22
- c.email = "test@email.cz"
23
- c.api_key = "XXXXXXXXXXX"
24
- c.account = "testaccount"
25
- end
26
-
27
- assert_equal "Fakturoid ruby gem (test@email.cz)", config.user_agent
28
- end
29
-
30
- should "return correct endpoints" do
31
- config = Fakturoid::Config.new do |c|
32
- c.email = "test@email.cz"
33
- c.api_key = "XXXXXXXXXXX"
34
- c.account = "testaccount"
35
- end
36
-
37
- assert_equal "https://app.fakturoid.cz/api/v2/accounts/testaccount", config.endpoint
38
- assert_equal "https://app.fakturoid.cz/api/v2", config.endpoint_without_account
39
- end
40
- end
@@ -1,8 +0,0 @@
1
- {
2
- "status": "Account blocked",
3
- "overdue_invoices": [
4
- {
5
- "invoice_url": "http://app.fakturoid.dev/robot/p/3WfeLRO5HZ/2015-0002"
6
- }
7
- ]
8
- }
@@ -1,81 +0,0 @@
1
- {
2
- "id": 5,
3
- "proforma": false,
4
- "number": "2012-0004",
5
- "variable_symbol": "20120004",
6
- "your_name": "Alexandr Hejsek",
7
- "your_street": "Hopsinkov\u00e1 14",
8
- "your_street2": null,
9
- "your_city": "Praha",
10
- "your_zip": "10000",
11
- "your_country": "CZ",
12
- "your_registration_no": "87654321",
13
- "your_vat_no": "CZ87654321",
14
- "client_name": "Microsoft a. s.",
15
- "client_street": "Trojanova 1216/46",
16
- "client_street2": null,
17
- "client_city": "Praha",
18
- "client_zip": "11000",
19
- "client_country": "CZ",
20
- "client_registration_no": "28444501",
21
- "client_vat_no": "CZ28444501",
22
- "subject_id": 4,
23
- "generator_id": 4,
24
- "related_id": null,
25
- "correction": false,
26
- "correction_id": null,
27
- "token": "udDTG8Q88M",
28
- "status": "paid",
29
- "order_number": null,
30
- "issued_on": "2011-10-13",
31
- "taxable_fulfillment_due": "2011-10-13",
32
- "due": 10,
33
- "due_on": "2011-10-23",
34
- "sent_at": null,
35
- "paid_at": "2011-10-20T12:11:37+02:00",
36
- "reminder_sent_at": null,
37
- "accepted_at": null,
38
- "cancelled_at": null,
39
- "note": null,
40
- "footer_note": null,
41
- "bank_account": "1234/1234",
42
- "iban": null,
43
- "swift_bic": null,
44
- "payment_method": "bank",
45
- "currency": "CZK",
46
- "exchange_rate": "1.0",
47
- "language": "cz",
48
- "transferred_tax_liability": false,
49
- "vat_price_mode": "without_vat",
50
- "subtotal": "40000.0",
51
- "total": "48400.0",
52
- "native_subtotal": "40000.0",
53
- "native_total": "48400.0",
54
- "lines": [
55
- {
56
- "id": 1234,
57
- "name": "PC",
58
- "quantity": "1.0",
59
- "unit_name": "",
60
- "unit_price": "20000.0",
61
- "vat_rate": 21,
62
- "unit_price_without_vat": "20000.0",
63
- "unit_price_with_vat": "24200.0"
64
- },
65
- {
66
- "id": 1235,
67
- "name": "Notebook",
68
- "quantity": "1.0",
69
- "unit_name": "",
70
- "unit_price": "20000.0",
71
- "vat_rate": 21,
72
- "unit_price_without_vat": "20000.0",
73
- "unit_price_with_vat": "24200.0"
74
- }
75
- ],
76
- "html_url": "https://app.fakturoid.cz/applecorp/invoices/9",
77
- "public_html_url": "https://app.fakturoid.cz/applecorp/p/udDTG8Q88M/2012-0004",
78
- "url": "https://app.fakturoid.cz/api/v2/accounts/applecorp/invoices/9.json",
79
- "subject_url": "https://app.fakturoid.cz/api/v2/accounts/applecorp/subjects/4.json",
80
- "updated_at": "2012-05-13T12:11:37+02:00"
81
- }
Binary file
@@ -1,7 +0,0 @@
1
- {
2
- "errors": {
3
- "number": [
4
- "je povinná položka"
5
- ]
6
- }
7
- }
@@ -1,52 +0,0 @@
1
- [
2
- {
3
- "id": 6,
4
- "custom_id": null,
5
- "type": "customer",
6
- "name": "Apple Czech s.r.o.",
7
- "street": "Klimentská 1216/46",
8
- "street2": null,
9
- "city": "Praha",
10
- "zip": "11000",
11
- "country": "CZ",
12
- "registration_no": "28897501",
13
- "vat_no": "CZ28897501",
14
- "bank_account": null,
15
- "iban": null,
16
- "variable_symbol": "",
17
- "full_name": null,
18
- "email": "",
19
- "email_copy": null,
20
- "phone": null,
21
- "web": "https://www.apple.cz",
22
- "avatar_url": "https://ssl.fakturoid.cz/images/company-contact.png",
23
- "html_url": "https://app.fakturoid.cz/applecorp/subjects/6",
24
- "url": "https://app.fakturoid.cz/api/v2/accounts/applecorp/subjects/6.json",
25
- "updated_at": "2012-05-13T12:11:38+02:00"
26
- },
27
- {
28
- "id": 28,
29
- "custom_id": null,
30
- "type": "supplier",
31
- "name": "MICROSOFT s.r.o.",
32
- "street": "Vyskočilova 1461/2a",
33
- "street2": null,
34
- "city": "Praha",
35
- "zip": "14000",
36
- "country": "Česká republika",
37
- "registration_no": "47123737",
38
- "vat_no": "CZ47123737",
39
- "bank_account": "",
40
- "iban": "",
41
- "variable_symbol": "1234567890",
42
- "full_name": "",
43
- "email": "",
44
- "email_copy": "",
45
- "phone": "",
46
- "web": "",
47
- "avatar_url": "https://ssl.fakturoid.cz/images/company-contact.png",
48
- "html_url": "https://app.fakturoid.cz/applecorp/subjects/28",
49
- "url": "https://app.fakturoid.cz/api/v2/accounts/applecorp/subjects/28.json",
50
- "updated_at": "2012-06-02T09:34:47+02:00"
51
- }
52
- ]
data/test/request_test.rb DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- class Fakturoid::RequestTest < Fakturoid::TestCase
6
- should "should return pdf" do
7
- pdf = load_fixture("invoice.pdf")
8
- test_connection = Faraday.new do |builder|
9
- builder.adapter :test do |stub|
10
- stub.get("invoices/5/download.pdf") { |_env| [200, { content_type: "application/pdf" }, pdf] }
11
- end
12
- builder.headers = { content_type: "application/pdf" }
13
- end
14
- Fakturoid::Request.any_instance.stubs(:connection).returns(test_connection)
15
-
16
- response = Fakturoid::Request.new(:get, "invoices/5/download.pdf", Fakturoid::Client::Invoice).call
17
- assert !response.json?
18
- assert_raises(NoMethodError) { response.name }
19
- end
20
- end