idoklad 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e39a28b3f6ad22b1ddeba2f77337d48212b0b4ad
4
+ data.tar.gz: 22176c205daab885963cf933b0a3456c728312fc
5
+ SHA512:
6
+ metadata.gz: 5f018b8edaa61bb5d7589c63d7b73557b7e56187de9499783b769ca64ccf9c838f3efd5d5e785ebc501ff9cd462850e94203aefbcd5f895353a0b40e5515cff5
7
+ data.tar.gz: f55a392b3c6b5779fc383842e21ce40629cb125d14c122e496b5d39213819ea3b8ae193b1e6b1fb2b5575a196069636a7996b0372ff23dc758be0773804674d4
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 CodeRocketCo
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.
File without changes
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'idoklad'
3
+ s.version = '0.0.1'
4
+ s.date = '2017-08-07'
5
+ s.summary = "iDoklad"
6
+ s.description = "A ruby gem for iDoklad.cz api."
7
+ s.authors = ["Jiri Prochazka"]
8
+ s.email = 'prochazka@coderocket.co'
9
+ s.homepage = 'https://github.com/CodeRocketCo/iDoklad'
10
+ s.license = 'MIT'
11
+ s.add_runtime_dependency "oauth2", '~> 1.4', '>= 1.4.0'
12
+ s.add_runtime_dependency "json", '~> 2.1.0', '>= 2.1.0'
13
+ s.files = %w[LICENSE.md README.md idoklad.gemspec] + Dir['lib/**/*.rb']
14
+ end
@@ -0,0 +1,21 @@
1
+ module Idoklad
2
+
3
+ API_URL = 'https://app.idoklad.cz'
4
+
5
+ class << self
6
+ attr_accessor :configuration
7
+ end
8
+
9
+ def self.configure
10
+ self.configuration ||= Configuration.new
11
+ yield(configuration)
12
+ end
13
+
14
+ class Configuration
15
+ attr_accessor :client_id, :client_secret
16
+ end
17
+ end
18
+
19
+ require 'idoklad/issued_invoices'
20
+ require 'idoklad/auth'
21
+ require 'idoklad/api_request'
@@ -0,0 +1,12 @@
1
+ module Idoklad::ApiRequest
2
+
3
+ def self.get(path)
4
+ @token ||= Idoklad::Auth.get_token
5
+
6
+ uri = URI.parse("#{Idoklad::API_URL}#{path}")
7
+ http = Net::HTTP.new(uri.host, uri.port)
8
+ http.use_ssl = true
9
+ http.get(uri.request_uri, {'Authorization' => "Bearer #{@token}"})
10
+ end
11
+
12
+ end
@@ -0,0 +1,21 @@
1
+ require 'oauth2'
2
+
3
+ module Idoklad::Auth
4
+
5
+ AUTHORIZE_URL = '/identity/server/connect/authorize'
6
+ TOKEN_URL = '/identity/server/connect/token'
7
+ SCOPE = 'idoklad_api'
8
+
9
+ def self.get_token
10
+ client = OAuth2::Client.new(
11
+ Idoklad.configuration.client_id,
12
+ Idoklad.configuration.client_secret,
13
+ :authorize_url => AUTHORIZE_URL,
14
+ :token_url => TOKEN_URL,
15
+ :site => Idoklad::API_URL
16
+ )
17
+
18
+ token = client.client_credentials.get_token(:scope => SCOPE)
19
+ token.token
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'json'
2
+ class Idoklad::IssuedInvoices
3
+
4
+ def self.get_list
5
+ response = Idoklad::ApiRequest.get '/developer/api/v2/IssuedInvoices'
6
+ return JSON.parse response.body
7
+ end
8
+
9
+ def self.get_default
10
+ response = Idoklad::ApiRequest.get '/developer/api/v2/IssuedInvoices/Default'
11
+ return JSON.parse response.body
12
+ end
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: idoklad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jiri Prochazka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.4.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.4'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.4.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: json
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 2.1.0
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.1.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 2.1.0
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.1.0
53
+ description: A ruby gem for iDoklad.cz api.
54
+ email: prochazka@coderocket.co
55
+ executables: []
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - LICENSE.md
60
+ - README.md
61
+ - idoklad.gemspec
62
+ - lib/idoklad.rb
63
+ - lib/idoklad/api_request.rb
64
+ - lib/idoklad/auth.rb
65
+ - lib/idoklad/issued_invoices.rb
66
+ homepage: https://github.com/CodeRocketCo/iDoklad
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.6.8
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: iDoklad
90
+ test_files: []