fattura24 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +2 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE +21 -0
  5. data/README.md +186 -0
  6. data/Rakefile +16 -0
  7. data/docs/Fattura24.html +197 -0
  8. data/docs/Fattura24/Api.html +497 -0
  9. data/docs/Fattura24/Api/Response.html +371 -0
  10. data/docs/Fattura24/Configuration.html +176 -0
  11. data/docs/Fattura24/DocumentType.html +133 -0
  12. data/docs/Fattura24/Error.html +104 -0
  13. data/docs/Fattura24/InvalidParams.html +104 -0
  14. data/docs/Fattura24/MissingApiKey.html +157 -0
  15. data/docs/Fattura24/MissingInput.html +104 -0
  16. data/docs/Fattura24/NotSerializable.html +104 -0
  17. data/docs/Fattura24/Utils.html +232 -0
  18. data/docs/README_md.html +273 -0
  19. data/docs/created.rid +10 -0
  20. data/docs/css/fonts.css +167 -0
  21. data/docs/css/rdoc.css +619 -0
  22. data/docs/fonts/Lato-Light.ttf +0 -0
  23. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  24. data/docs/fonts/Lato-Regular.ttf +0 -0
  25. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  26. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  27. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  28. data/docs/images/add.png +0 -0
  29. data/docs/images/arrow_up.png +0 -0
  30. data/docs/images/brick.png +0 -0
  31. data/docs/images/brick_link.png +0 -0
  32. data/docs/images/bug.png +0 -0
  33. data/docs/images/bullet_black.png +0 -0
  34. data/docs/images/bullet_toggle_minus.png +0 -0
  35. data/docs/images/bullet_toggle_plus.png +0 -0
  36. data/docs/images/date.png +0 -0
  37. data/docs/images/delete.png +0 -0
  38. data/docs/images/find.png +0 -0
  39. data/docs/images/loadingAnimation.gif +0 -0
  40. data/docs/images/macFFBgHack.png +0 -0
  41. data/docs/images/package.png +0 -0
  42. data/docs/images/page_green.png +0 -0
  43. data/docs/images/page_white_text.png +0 -0
  44. data/docs/images/page_white_width.png +0 -0
  45. data/docs/images/plugin.png +0 -0
  46. data/docs/images/ruby.png +0 -0
  47. data/docs/images/tag_blue.png +0 -0
  48. data/docs/images/tag_green.png +0 -0
  49. data/docs/images/transparent.png +0 -0
  50. data/docs/images/wrench.png +0 -0
  51. data/docs/images/wrench_orange.png +0 -0
  52. data/docs/images/zoom.png +0 -0
  53. data/docs/index.html +283 -0
  54. data/docs/js/darkfish.js +84 -0
  55. data/docs/js/navigation.js +105 -0
  56. data/docs/js/navigation.js.gz +0 -0
  57. data/docs/js/search.js +110 -0
  58. data/docs/js/search_index.js +1 -0
  59. data/docs/js/search_index.js.gz +0 -0
  60. data/docs/js/searcher.js +229 -0
  61. data/docs/js/searcher.js.gz +0 -0
  62. data/docs/table_of_contents.html +216 -0
  63. data/fattura24.gemspec +54 -0
  64. data/lib/fattura24.rb +28 -0
  65. data/lib/fattura24/api/client.rb +160 -0
  66. data/lib/fattura24/api/response.rb +70 -0
  67. data/lib/fattura24/configuration.rb +14 -0
  68. data/lib/fattura24/document_type.rb +15 -0
  69. data/lib/fattura24/errors.rb +20 -0
  70. data/lib/fattura24/utils.rb +38 -0
  71. data/lib/fattura24/version.rb +5 -0
  72. metadata +267 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0e934fe8759d86f4496f479edf1a3f08e4f76897f33ba01b8bd719b3e6ed948b
4
+ data.tar.gz: 15df3a4e5e7bea14a0faa4c6efa27f4f0c3d38799a5f67468ff73559e7225138
5
+ SHA512:
6
+ metadata.gz: 9a85ba7a87636c19a547b98587ad1e1ab5678529571d24e582e49bf8a8ab550ea096b4f4a15600b6fefe504029b1371f8267707fe6893d1ec91f123effc0c7e7
7
+ data.tar.gz: 4518e73a7700f1a63ec15729b42d24866dc00fece3a601e5b6f51180093dec248318539a974a7ba72efcba52c7433fc68d0aaed94be95b01e9934388444ea888
@@ -0,0 +1,2 @@
1
+ ### 1.0.0
2
+ - First development version
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in fattura24.gemspec
8
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Stefano Nada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,186 @@
1
+ # Fattura24
2
+
3
+ [![Build Status](https://travis-ci.org/snada/fattura24.svg?branch=master)](https://travis-ci.org/snada/fattura24)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/8db0d6f2c8e567f09319/maintainability)](https://codeclimate.com/github/snada/fattura24/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/8db0d6f2c8e567f09319/test_coverage)](https://codeclimate.com/github/snada/fattura24/test_coverage)
6
+
7
+ Simple, lightweight and with minimal dependencies ruby 2 wrapper for the [Fattura24](https://www.fattura24.com/) apis.
8
+
9
+ Tested and developed on rubies 2.4+.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'fattura24'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install fattura24
26
+
27
+ ## Usage
28
+
29
+ First, configure the module by adding your api key.
30
+
31
+ ```ruby
32
+ Fattura24.configure do |configuration|
33
+ configuration.api_key = 'your_secret_key'
34
+ end
35
+ ```
36
+
37
+ Once set, you can call the api methods to get the responses you need.
38
+
39
+ ```ruby
40
+ # This method checks if your key is valid
41
+ response = Fattura24::Api.test_key
42
+
43
+ # Check for possible network errors, returns true on ok (200) responses
44
+ puts response.success?
45
+
46
+ # Call .to_h to get a hash version of the xml response
47
+ puts response.to_h[:returnCode]
48
+
49
+ # If you need more info, check the raw Net::HTTP response object
50
+ raw_response = response.http_response
51
+ ```
52
+
53
+ ### Api calls
54
+
55
+ You can take inspiration on the params to provide to your calls by visiting the [official documentation](https://www.fattura24.com/api-documentazione/).
56
+ Generally speaking, this library will translate the structure of your hash to an equivalent xml document camelizing all of your keys.
57
+
58
+ #### TestKey, GetTemplate, GetPdc, GetNumerator
59
+
60
+ All of these calls don't require any argument. Simply call them and inspect their response:
61
+
62
+ ```ruby
63
+ r = Fattura24::Api.test_key
64
+ r = Fattura24::Api.get_template
65
+ r = Fattura24::Api.get_pdc
66
+ r = Fattura24::Api.get_numerator
67
+
68
+ puts r.to_h
69
+ ```
70
+
71
+ #### SaveCustomer
72
+
73
+ ```ruby
74
+ r = Fattura24::Api.save_customer(
75
+ customer_name: 'John Doe',
76
+ customer_address: '100 Yonge Street',
77
+ customer_city: 'Toronto',
78
+ customer_country: 'CA',
79
+ customer_fiscal_code: 'Set this for persons',
80
+ customer_vat_code: 'vat',
81
+ customer_email: 'some@email.com',
82
+ fe_customer_pec: 'a@pec.com'
83
+ )
84
+ ```
85
+
86
+ #### SaveDocument
87
+
88
+ ```ruby
89
+ r = Fattura24::Api.save_document(
90
+ document_type: Fattura24::DocumentType::ELECTRONIC_INVOICE,
91
+ customer_name: 'John Doe',
92
+ customer_fiscal_code: 'NDASFN89A27L219Y',
93
+ customer_address: '100 Yonge Street',
94
+ customer_city: 'Toronto',
95
+ customer_country: 'CA',
96
+ payments: [
97
+ {
98
+ date: '2020-04-27',
99
+ amount: '100',
100
+ paid: 'true'
101
+ }
102
+ ],
103
+ rows: [
104
+ {
105
+ code: '001',
106
+ description: 'Element description',
107
+ qty: '1',
108
+ price: '100'
109
+ }
110
+ ],
111
+ id_template: '65',
112
+ send_email: 'true',
113
+ object: 'test',
114
+ total: 100,
115
+ total_without_tax: 100,
116
+ vat_amount: 0
117
+ )
118
+ ```
119
+
120
+ #### GetFile
121
+
122
+ ```ruby
123
+ r = Fattura24::Api.get_file('1234567')
124
+
125
+ # true if response content is actually a file
126
+ if r.pdf?
127
+ File.write('invoice.pdf', r.to_s)
128
+ end
129
+ ```
130
+
131
+ #### GetProduct
132
+
133
+ ```ruby
134
+ # gets all products
135
+ r = Fattura24::Api.get_product
136
+
137
+ # filters by code
138
+ r = Fattura24::Api.get_product(code: 'some_code')
139
+
140
+ # filters by category
141
+ r = Fattura24::Api.get_product(category: 'some_category')
142
+
143
+ # combines both
144
+ r = Fattura24::Api.get_product({
145
+ code: 'some_code',
146
+ category: 'some_category'
147
+ })
148
+ ```
149
+
150
+ ## Development
151
+
152
+ After checking out the repo, run `bundle` to install dependencies. You can run `bin/console` for an interactive prompt that will allow you to experiment.
153
+
154
+ To install this gem onto your local machine, run `bundle exec rake install`.
155
+
156
+ To run tests and linting, simply run `bundle exec rake`.
157
+
158
+ When you edit something, include appropriate docs and rebuild them by running `bundle exec rake rdoc`.
159
+
160
+ If you have docker installed, you can test against all of the supported ruby versions by running:
161
+
162
+ ```bash
163
+ $ make build
164
+ ```
165
+
166
+ That will build the required docker images, and then you can run tests with:
167
+
168
+ ```bash
169
+ $ make
170
+ ```
171
+
172
+ ### Release of a new version
173
+
174
+ To release a new version, update the version number in `lib/fattura24/version.rb`. Make sure version tests are still satisfied.
175
+ Then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
176
+
177
+ ## Contributing
178
+
179
+ Everyone is welcome to contribute.
180
+ This project tries to follow the git-flow branching model. Open a branch named `feature/<name>` and make a PR against `develop`.
181
+
182
+ Please, make sure you include appropriate unit tests to the codebase (also check coverage) and that your code satisfies rubocop checks.
183
+
184
+ ## License
185
+
186
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+ require 'rdoc/task'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+ RuboCop::RakeTask.new
10
+ RDoc::Task.new do |rdoc|
11
+ rdoc.main = 'README.md'
12
+ rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
13
+ rdoc.rdoc_dir = 'docs'
14
+ end
15
+
16
+ task default: %i[spec rubocop]
@@ -0,0 +1,197 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>module Fattura24 - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+
25
+ <body id="top" role="document" class="module">
26
+ <nav role="navigation">
27
+ <div id="project-navigation">
28
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
29
+ <h2>
30
+ <a href="./index.html" rel="home">Home</a>
31
+ </h2>
32
+
33
+ <div id="table-of-contents-navigation">
34
+ <a href="./table_of_contents.html#pages">Pages</a>
35
+ <a href="./table_of_contents.html#classes">Classes</a>
36
+ <a href="./table_of_contents.html#methods">Methods</a>
37
+ </div>
38
+ </div>
39
+
40
+ <div id="search-section" role="search" class="project-section initially-hidden">
41
+ <form action="#" method="get" accept-charset="utf-8">
42
+ <div id="search-field-wrapper">
43
+ <input id="search-field" role="combobox" aria-label="Search"
44
+ aria-autocomplete="list" aria-controls="search-results"
45
+ type="text" name="search" placeholder="Search" spellcheck="false"
46
+ title="Type to search, Up and Down to navigate, Enter to load">
47
+ </div>
48
+
49
+ <ul id="search-results" aria-label="Search Results"
50
+ aria-busy="false" aria-expanded="false"
51
+ aria-atomic="false" class="initially-hidden"></ul>
52
+ </form>
53
+ </div>
54
+
55
+ </div>
56
+
57
+
58
+
59
+ <div id="class-metadata">
60
+
61
+
62
+
63
+
64
+ <!-- Method Quickref -->
65
+ <div id="method-list-section" class="nav-section">
66
+ <h3>Methods</h3>
67
+
68
+ <ul class="link-list" role="directory">
69
+
70
+ <li ><a href="#method-c-configuration">::configuration</a>
71
+
72
+ <li ><a href="#method-c-configure">::configure</a>
73
+
74
+ </ul>
75
+ </div>
76
+
77
+ </div>
78
+ </nav>
79
+
80
+ <main role="main" aria-labelledby="module-Fattura24">
81
+ <h1 id="module-Fattura24" class="module">
82
+ module Fattura24
83
+ </h1>
84
+
85
+ <section class="description">
86
+
87
+ </section>
88
+
89
+
90
+ <section id="5Buntitled-5D" class="documentation-section">
91
+
92
+
93
+
94
+
95
+
96
+ <section class="constants-list">
97
+ <header>
98
+ <h3>Constants</h3>
99
+ </header>
100
+ <dl>
101
+
102
+ <dt id="VERSION">VERSION
103
+
104
+ <dd>
105
+
106
+
107
+ </dl>
108
+ </section>
109
+
110
+
111
+
112
+
113
+
114
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
115
+ <header>
116
+ <h3>Public Class Methods</h3>
117
+ </header>
118
+
119
+
120
+ <div id="method-c-configuration" class="method-detail ">
121
+
122
+ <div class="method-heading">
123
+ <span class="method-name">configuration</span><span
124
+ class="method-args">()</span>
125
+
126
+ <span class="method-click-advice">click to toggle source</span>
127
+
128
+ </div>
129
+
130
+
131
+ <div class="method-description">
132
+
133
+ <p>Returns current configuration object</p>
134
+
135
+
136
+
137
+
138
+ <div class="method-source-code" id="configuration-source">
139
+ <pre><span class="ruby-comment"># File lib/fattura24.rb, line 18</span>
140
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">configuration</span>
141
+ <span class="ruby-ivar">@configuration</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">new</span>
142
+ <span class="ruby-keyword">end</span></pre>
143
+ </div>
144
+
145
+ </div>
146
+
147
+
148
+
149
+
150
+ </div>
151
+
152
+
153
+ <div id="method-c-configure" class="method-detail ">
154
+
155
+ <div class="method-heading">
156
+ <span class="method-name">configure</span><span
157
+ class="method-args">() { |configuration| ... }</span>
158
+
159
+ <span class="method-click-advice">click to toggle source</span>
160
+
161
+ </div>
162
+
163
+
164
+ <div class="method-description">
165
+
166
+ <p>Calling this method will yield to a block passing the <code>configuration</code> object as parameter.</p>
167
+
168
+
169
+
170
+
171
+ <div class="method-source-code" id="configure-source">
172
+ <pre><span class="ruby-comment"># File lib/fattura24.rb, line 25</span>
173
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">configure</span>
174
+ <span class="ruby-keyword">yield</span> <span class="ruby-identifier">configuration</span>
175
+ <span class="ruby-keyword">end</span></pre>
176
+ </div>
177
+
178
+ </div>
179
+
180
+
181
+
182
+
183
+ </div>
184
+
185
+
186
+ </section>
187
+
188
+ </section>
189
+ </main>
190
+
191
+
192
+ <footer id="validator-badges" role="contentinfo">
193
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
194
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
195
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
196
+ </footer>
197
+
@@ -0,0 +1,497 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>module Fattura24::Api - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../";
11
+ var index_rel_prefix = "../";
12
+ </script>
13
+
14
+ <script src="../js/navigation.js" defer></script>
15
+ <script src="../js/search.js" defer></script>
16
+ <script src="../js/search_index.js" defer></script>
17
+ <script src="../js/searcher.js" defer></script>
18
+ <script src="../js/darkfish.js" defer></script>
19
+
20
+ <link href="../css/fonts.css" rel="stylesheet">
21
+ <link href="../css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+
25
+ <body id="top" role="document" class="module">
26
+ <nav role="navigation">
27
+ <div id="project-navigation">
28
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
29
+ <h2>
30
+ <a href="../index.html" rel="home">Home</a>
31
+ </h2>
32
+
33
+ <div id="table-of-contents-navigation">
34
+ <a href="../table_of_contents.html#pages">Pages</a>
35
+ <a href="../table_of_contents.html#classes">Classes</a>
36
+ <a href="../table_of_contents.html#methods">Methods</a>
37
+ </div>
38
+ </div>
39
+
40
+ <div id="search-section" role="search" class="project-section initially-hidden">
41
+ <form action="#" method="get" accept-charset="utf-8">
42
+ <div id="search-field-wrapper">
43
+ <input id="search-field" role="combobox" aria-label="Search"
44
+ aria-autocomplete="list" aria-controls="search-results"
45
+ type="text" name="search" placeholder="Search" spellcheck="false"
46
+ title="Type to search, Up and Down to navigate, Enter to load">
47
+ </div>
48
+
49
+ <ul id="search-results" aria-label="Search Results"
50
+ aria-busy="false" aria-expanded="false"
51
+ aria-atomic="false" class="initially-hidden"></ul>
52
+ </form>
53
+ </div>
54
+
55
+ </div>
56
+
57
+
58
+
59
+ <div id="class-metadata">
60
+
61
+
62
+
63
+
64
+ <!-- Method Quickref -->
65
+ <div id="method-list-section" class="nav-section">
66
+ <h3>Methods</h3>
67
+
68
+ <ul class="link-list" role="directory">
69
+
70
+ <li ><a href="#method-c-get_file">::get_file</a>
71
+
72
+ <li ><a href="#method-c-get_numerator">::get_numerator</a>
73
+
74
+ <li ><a href="#method-c-get_pdc">::get_pdc</a>
75
+
76
+ <li ><a href="#method-c-get_product">::get_product</a>
77
+
78
+ <li ><a href="#method-c-get_template">::get_template</a>
79
+
80
+ <li ><a href="#method-c-request">::request</a>
81
+
82
+ <li ><a href="#method-c-save_customer">::save_customer</a>
83
+
84
+ <li ><a href="#method-c-save_document">::save_document</a>
85
+
86
+ <li ><a href="#method-c-save_item">::save_item</a>
87
+
88
+ <li ><a href="#method-c-test_key">::test_key</a>
89
+
90
+ </ul>
91
+ </div>
92
+
93
+ </div>
94
+ </nav>
95
+
96
+ <main role="main" aria-labelledby="module-Fattura24::Api">
97
+ <h1 id="module-Fattura24::Api" class="module">
98
+ module Fattura24::Api
99
+ </h1>
100
+
101
+ <section class="description">
102
+
103
+ </section>
104
+
105
+
106
+ <section id="5Buntitled-5D" class="documentation-section">
107
+
108
+
109
+
110
+
111
+
112
+ <section class="constants-list">
113
+ <header>
114
+ <h3>Constants</h3>
115
+ </header>
116
+ <dl>
117
+
118
+ <dt id="API_HOST">API_HOST
119
+
120
+ <dd><p>This library uses <a href="https://fattura24.com">fattura24.com</a> v0.3 apis. Check their docs <a href="https://www.fattura24.com/api-documentazione/">here</a>.</p>
121
+
122
+
123
+ </dl>
124
+ </section>
125
+
126
+
127
+
128
+
129
+
130
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
131
+ <header>
132
+ <h3>Public Class Methods</h3>
133
+ </header>
134
+
135
+
136
+ <div id="method-c-get_file" class="method-detail ">
137
+
138
+ <div class="method-heading">
139
+ <span class="method-name">get_file</span><span
140
+ class="method-args">(id)</span>
141
+
142
+ <span class="method-click-advice">click to toggle source</span>
143
+
144
+ </div>
145
+
146
+
147
+ <div class="method-description">
148
+
149
+ <p>Donwloads a pdf file for an existing document. Requires an existing document id, throws <a href="MissingInput.html">MissingInput</a> when passing a nil <code>id</code>. Returns a <a href="Api/Response.html">Response</a> object: refer to it&#39;s documentation to detect a binary file and instruction to save it to disk.</p>
150
+
151
+
152
+
153
+
154
+ <div class="method-source-code" id="get_file-source">
155
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 71</span>
156
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_file</span>(<span class="ruby-identifier">id</span>)
157
+ <span class="ruby-identifier">raise</span>(<span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingInput</span>, <span class="ruby-string">&#39;You need to provide an id&#39;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">id</span>
158
+
159
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/GetFile&#39;</span>, { <span class="ruby-value">docId:</span> <span class="ruby-identifier">id</span> })
160
+ <span class="ruby-keyword">end</span></pre>
161
+ </div>
162
+
163
+ </div>
164
+
165
+
166
+
167
+
168
+ </div>
169
+
170
+
171
+ <div id="method-c-get_numerator" class="method-detail ">
172
+
173
+ <div class="method-heading">
174
+ <span class="method-name">get_numerator</span><span
175
+ class="method-args">()</span>
176
+
177
+ <span class="method-click-advice">click to toggle source</span>
178
+
179
+ </div>
180
+
181
+
182
+ <div class="method-description">
183
+
184
+ <p>Gets numerator list. Returns a <a href="Api/Response.html">Response</a> object.</p>
185
+
186
+
187
+
188
+
189
+ <div class="method-source-code" id="get_numerator-source">
190
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 60</span>
191
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_numerator</span>
192
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/GetNumerator&#39;</span>)
193
+ <span class="ruby-keyword">end</span></pre>
194
+ </div>
195
+
196
+ </div>
197
+
198
+
199
+
200
+
201
+ </div>
202
+
203
+
204
+ <div id="method-c-get_pdc" class="method-detail ">
205
+
206
+ <div class="method-heading">
207
+ <span class="method-name">get_pdc</span><span
208
+ class="method-args">()</span>
209
+
210
+ <span class="method-click-advice">click to toggle source</span>
211
+
212
+ </div>
213
+
214
+
215
+ <div class="method-description">
216
+
217
+ <p>Gets &#39;piano dei conti&#39; Returns a <a href="Api/Response.html">Response</a> object.</p>
218
+
219
+
220
+
221
+
222
+ <div class="method-source-code" id="get_pdc-source">
223
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 53</span>
224
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_pdc</span>
225
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/GetPdc&#39;</span>)
226
+ <span class="ruby-keyword">end</span></pre>
227
+ </div>
228
+
229
+ </div>
230
+
231
+
232
+
233
+
234
+ </div>
235
+
236
+
237
+ <div id="method-c-get_product" class="method-detail ">
238
+
239
+ <div class="method-heading">
240
+ <span class="method-name">get_product</span><span
241
+ class="method-args">(options = {})</span>
242
+
243
+ <span class="method-click-advice">click to toggle source</span>
244
+
245
+ </div>
246
+
247
+
248
+ <div class="method-description">
249
+
250
+ <p>Gets a list of products. You can pass a Hash containing a <code>code</code> or <code>category</code> to filter your existing products by them. Throws a <a href="InvalidParams.html">InvalidParams</a> when passing an hash containing unrecognized options. Returns a <a href="Api/Response.html">Response</a> object.</p>
251
+
252
+
253
+
254
+
255
+ <div class="method-source-code" id="get_product-source">
256
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 85</span>
257
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_product</span>(<span class="ruby-identifier">options</span> = {})
258
+ <span class="ruby-identifier">validate_params</span>(<span class="ruby-identifier">options</span>, <span class="ruby-node">%i[code category]</span>)
259
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/GetProduct&#39;</span>, <span class="ruby-identifier">options</span>)
260
+ <span class="ruby-keyword">end</span></pre>
261
+ </div>
262
+
263
+ </div>
264
+
265
+
266
+
267
+
268
+ </div>
269
+
270
+
271
+ <div id="method-c-get_template" class="method-detail ">
272
+
273
+ <div class="method-heading">
274
+ <span class="method-name">get_template</span><span
275
+ class="method-args">()</span>
276
+
277
+ <span class="method-click-advice">click to toggle source</span>
278
+
279
+ </div>
280
+
281
+
282
+ <div class="method-description">
283
+
284
+ <p>Gets a list of document templates. Returns a <a href="Api/Response.html">Response</a> object.</p>
285
+
286
+
287
+
288
+
289
+ <div class="method-source-code" id="get_template-source">
290
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 46</span>
291
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">get_template</span>
292
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/GetTemplate&#39;</span>)
293
+ <span class="ruby-keyword">end</span></pre>
294
+ </div>
295
+
296
+ </div>
297
+
298
+
299
+
300
+
301
+ </div>
302
+
303
+
304
+ <div id="method-c-request" class="method-detail ">
305
+
306
+ <div class="method-heading">
307
+ <span class="method-name">request</span><span
308
+ class="method-args">(path, body = {})</span>
309
+
310
+ <span class="method-click-advice">click to toggle source</span>
311
+
312
+ </div>
313
+
314
+
315
+ <div class="method-description">
316
+
317
+ <p>Performs a generic request on the api endpoint using Ruby&#39;s <a href="https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html">Net::HTTP</a>. All the other api methods call this one. Parameter <code>path</code> should always be prepended with &#39;/&#39;. Body will default to an empty hash. Returns a <a href="Api/Response.html">Response</a> object.</p>
318
+
319
+
320
+
321
+
322
+ <div class="method-source-code" id="request-source">
323
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 19</span>
324
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">request</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">body</span> = {})
325
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingApiKey</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Fattura24</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">api_key</span>
326
+
327
+ <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">&quot;#{API_HOST}#{path}&quot;</span>)
328
+ <span class="ruby-identifier">request</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>)
329
+ <span class="ruby-identifier">request</span>.<span class="ruby-identifier">set_form_data</span>(<span class="ruby-identifier">inject_api_key</span>(<span class="ruby-identifier">body</span>))
330
+
331
+ <span class="ruby-identifier">req_options</span> = { <span class="ruby-value">use_ssl:</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;https&#39;</span> }
332
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">hostname</span>, <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>, <span class="ruby-identifier">req_options</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
333
+ <span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">request</span>)
334
+ <span class="ruby-keyword">end</span>
335
+
336
+ <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">response</span>)
337
+ <span class="ruby-keyword">end</span></pre>
338
+ </div>
339
+
340
+ </div>
341
+
342
+
343
+
344
+
345
+ </div>
346
+
347
+
348
+ <div id="method-c-save_customer" class="method-detail ">
349
+
350
+ <div class="method-heading">
351
+ <span class="method-name">save_customer</span><span
352
+ class="method-args">(data = {})</span>
353
+
354
+ <span class="method-click-advice">click to toggle source</span>
355
+
356
+ </div>
357
+
358
+
359
+ <div class="method-description">
360
+
361
+ <p>Saves a customer in your contact list. Any <code>nil</code> parameter will be deeply removed by using the <a href="Utils.html#method-c-crush">crush</a> utility. Returns a <a href="Api/Response.html">Response</a> object.</p>
362
+
363
+
364
+
365
+
366
+ <div class="method-source-code" id="save_customer-source">
367
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 97</span>
368
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">save_customer</span>(<span class="ruby-identifier">data</span> = {})
369
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/SaveCustomer&#39;</span>, {
370
+ <span class="ruby-value">xml:</span> <span class="ruby-identifier">hash_to_xml</span>(<span class="ruby-identifier">data</span>)
371
+ })
372
+ <span class="ruby-keyword">end</span></pre>
373
+ </div>
374
+
375
+ </div>
376
+
377
+
378
+
379
+
380
+ </div>
381
+
382
+
383
+ <div id="method-c-save_document" class="method-detail ">
384
+
385
+ <div class="method-heading">
386
+ <span class="method-name">save_document</span><span
387
+ class="method-args">(data = {})</span>
388
+
389
+ <span class="method-click-advice">click to toggle source</span>
390
+
391
+ </div>
392
+
393
+
394
+ <div class="method-description">
395
+
396
+ <p>Use this to create documents. Pass a hash with the data, check the <a href="../README_md.html">README</a> file for examples. Use <a href="DocumentType.html">DocumentType</a> enums to specify document type. Any <code>nil</code> parameter will be deeply removed by using the <a href="Utils.html#method-c-crush">crush</a> utility. Returns a <a href="Api/Response.html">Response</a> object.</p>
397
+
398
+
399
+
400
+
401
+ <div class="method-source-code" id="save_document-source">
402
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 111</span>
403
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">save_document</span>(<span class="ruby-identifier">data</span> = {})
404
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/SaveDocument&#39;</span>, {
405
+ <span class="ruby-value">xml:</span> <span class="ruby-identifier">hash_to_xml</span>(<span class="ruby-identifier">data</span>)
406
+ })
407
+ <span class="ruby-keyword">end</span></pre>
408
+ </div>
409
+
410
+ </div>
411
+
412
+
413
+
414
+
415
+ </div>
416
+
417
+
418
+ <div id="method-c-save_item" class="method-detail ">
419
+
420
+ <div class="method-heading">
421
+ <span class="method-name">save_item</span><span
422
+ class="method-args">(data = {})</span>
423
+
424
+ <span class="method-click-advice">click to toggle source</span>
425
+
426
+ </div>
427
+
428
+
429
+ <div class="method-description">
430
+
431
+ <p>Creates a credit. Any <code>nil</code> parameter will be deeply removed by using the <a href="Utils.html#method-c-crush">crush</a> utility. Returns a <a href="Api/Response.html">Response</a> object.</p>
432
+
433
+
434
+
435
+
436
+ <div class="method-source-code" id="save_item-source">
437
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 122</span>
438
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">save_item</span>(<span class="ruby-identifier">data</span> = {})
439
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/SaveItem&#39;</span>, {
440
+ <span class="ruby-value">xml:</span> <span class="ruby-identifier">hash_to_xml</span>(<span class="ruby-identifier">data</span>)
441
+ })
442
+ <span class="ruby-keyword">end</span></pre>
443
+ </div>
444
+
445
+ </div>
446
+
447
+
448
+
449
+
450
+ </div>
451
+
452
+
453
+ <div id="method-c-test_key" class="method-detail ">
454
+
455
+ <div class="method-heading">
456
+ <span class="method-name">test_key</span><span
457
+ class="method-args">()</span>
458
+
459
+ <span class="method-click-advice">click to toggle source</span>
460
+
461
+ </div>
462
+
463
+
464
+ <div class="method-description">
465
+
466
+ <p>Tests validity of your api key. Returns a <a href="Api/Response.html">Response</a> object.</p>
467
+
468
+
469
+
470
+
471
+ <div class="method-source-code" id="test_key-source">
472
+ <pre><span class="ruby-comment"># File lib/fattura24/api/client.rb, line 37</span>
473
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">test_key</span>
474
+ <span class="ruby-identifier">request</span>(<span class="ruby-string">&#39;/TestKey&#39;</span>)
475
+ <span class="ruby-keyword">end</span></pre>
476
+ </div>
477
+
478
+ </div>
479
+
480
+
481
+
482
+
483
+ </div>
484
+
485
+
486
+ </section>
487
+
488
+ </section>
489
+ </main>
490
+
491
+
492
+ <footer id="validator-badges" role="contentinfo">
493
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
494
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
495
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
496
+ </footer>
497
+