idoklad 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e39a28b3f6ad22b1ddeba2f77337d48212b0b4ad
4
- data.tar.gz: 22176c205daab885963cf933b0a3456c728312fc
3
+ metadata.gz: 8b044099c69076a54c725f4be4802a742d3b59e4
4
+ data.tar.gz: 8562c172bd25cc59b373d6be6f39b3360f01f1ca
5
5
  SHA512:
6
- metadata.gz: 5f018b8edaa61bb5d7589c63d7b73557b7e56187de9499783b769ca64ccf9c838f3efd5d5e785ebc501ff9cd462850e94203aefbcd5f895353a0b40e5515cff5
7
- data.tar.gz: f55a392b3c6b5779fc383842e21ce40629cb125d14c122e496b5d39213819ea3b8ae193b1e6b1fb2b5575a196069636a7996b0372ff23dc758be0773804674d4
6
+ metadata.gz: 37c99ef6fc1182794a7f23bedf3228ba5fe2b73fa3d90edbb8061c4561ddbc023739d89383f0576f31bae100d9d8d44fe3f0807ed7326768e4ce7c0077a7b5b3
7
+ data.tar.gz: 220c0c946585e963debb2be4e380d401fa55e8c32abafeb67469397253c65b2e3fea0305ec0c2113788825a7bc79db390848f6e25d5dbaa466f89a45fba16b77
data/README.md CHANGED
@@ -0,0 +1,51 @@
1
+ # iDoklad
2
+
3
+ This is a ruby gem for Czech accounting cloud system [iDoklad.cz](http://idoklad.cz) api.
4
+
5
+ You can find official iDoklad.cz api documentation on https://app.idoklad.cz/developer.
6
+
7
+ ## Installation
8
+
9
+ To install gem write in console:
10
+
11
+ > gem install idoklad
12
+
13
+ Or in Gemfile:
14
+
15
+ gem 'idoklad'
16
+
17
+ ## Configuration
18
+
19
+ To get gem working you must create an iDoklad initializer file and insert **client_id** and **client_secret** values which you can obtain in [iDoklad.cz administration](https://app.idoklad.cz/Setting/LogonUser).
20
+ Create *config/initializers/idoklad.rb* file with following content:
21
+
22
+ # config/initializers/idoklad.rb
23
+
24
+ require 'idoklad'
25
+ Idoklad.configure do |c|
26
+ c.client_id = **INSERT_YOUR_CLIENT_ID**
27
+ c.client_secret = **INSERT_YOUR_CLIENT_SECRET**
28
+ end
29
+
30
+ Of course replace **\*\*INSERT_YOUR_CLIENT_ID\*\*** and **\*\*INSERT_YOUR_CLIENT_SECRET\*\*** with proper values.
31
+
32
+ ## Functionality
33
+
34
+ - [Getting List of Invoices](#getting-list-of-invoices)
35
+ - [Getting the Default Invoice](#getting-default-invoice)
36
+
37
+ ### Getting List of Invoices
38
+
39
+ It returns the list of all issued invoices:
40
+
41
+ @result = Idoklad::IssuedInvoices.get_list
42
+
43
+ ### Getting Default Invoice
44
+
45
+ Returns an empty invoice with initial values according to the agenda settings. Good for issuing new invoice.
46
+
47
+ @result = Idoklad::IssuedInvoices.get_default
48
+
49
+ ## Contribution
50
+
51
+ The functionality is being added as I find it required. If you want to contribute or you want me to add some functionality, just [write me](http://coderocket.co).
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'idoklad'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.date = '2017-08-07'
5
5
  s.summary = "iDoklad"
6
6
  s.description = "A ruby gem for iDoklad.cz api."
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Idoklad::ApiRequest
2
4
 
3
5
  def self.get(path)
@@ -8,5 +10,14 @@ module Idoklad::ApiRequest
8
10
  http.use_ssl = true
9
11
  http.get(uri.request_uri, {'Authorization' => "Bearer #{@token}"})
10
12
  end
11
-
13
+
14
+ def self.post(path, object)
15
+ @token ||= Idoklad::Auth.get_token
16
+
17
+ uri = URI.parse("#{Idoklad::API_URL}#{path}")
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ http.use_ssl = true
20
+ http.post(uri.request_uri, JSON.generate(object), {'Authorization' => "Bearer #{@token}", 'Content-type' => 'application/json'})
21
+ end
22
+
12
23
  end
@@ -11,4 +11,9 @@ class Idoklad::IssuedInvoices
11
11
  return JSON.parse response.body
12
12
  end
13
13
 
14
+ def self.create(invoice)
15
+ response = Idoklad::ApiRequest.post '/developer/api/v2/IssuedInvoices', invoice
16
+ return JSON.parse response.body
17
+ end
18
+
14
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idoklad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiri Prochazka