horizon_client 0.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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +24 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/horizon_client.gemspec +33 -0
- data/lib/horizon_client.rb +54 -0
- data/lib/horizon_client/version.rb +3 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb395e5f2b23f7735ab1549c681e256416f8a100
|
4
|
+
data.tar.gz: b6bea60d63ab9e74ce52b72028ee9fca85feaadd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 69411579c286d798d365526aab6197c66554eeb5a2d588644472ff9970b465a5470f9438e1e8737bf74e8244ca64bedfc53558f3c3dbe957ef49d2c64255bef0
|
7
|
+
data.tar.gz: ebe62d15894bd5e9666a1188d27a6537d8a457fe8a059b8fa97f7cfdecec58a1b5bac3c42684694f469c76804d90083cca5e5f51ed3b3d0df1e304295a7cbe58
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# HorizonClient
|
2
|
+
|
3
|
+
Client to use with Horizon REST xml API.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
client = HorizonClient.new
|
9
|
+
|
10
|
+
get_response = client.get('example')
|
11
|
+
|
12
|
+
post_response = client.post('example', 'post body')
|
13
|
+
```
|
14
|
+
|
15
|
+
`get_response` will be parsed from xml to hash.
|
16
|
+
|
17
|
+
|
18
|
+
### Necessary environment variables
|
19
|
+
|
20
|
+
* **HORIZON_REST_URL** e.x. http://user:pass@ip:port/rest. Note the "/rest" part
|
21
|
+
|
22
|
+
## Development
|
23
|
+
|
24
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "horizon_client"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'horizon_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "horizon_client"
|
8
|
+
spec.version = HorizonClient::VERSION
|
9
|
+
spec.authors = ["MAK IT"]
|
10
|
+
spec.email = ["martins.lapsa@makit.lv"]
|
11
|
+
|
12
|
+
spec.summary = %q{Client for Horizon accounting REST xml API.}
|
13
|
+
spec.description = "Client for Horizon by VISMA accounting REST xml API."
|
14
|
+
spec.homepage = "http://rubygems.org/gems/horizon_client"
|
15
|
+
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "webmock", "~> 2.0"
|
29
|
+
|
30
|
+
spec.add_dependency 'faraday', '~> 0.11'
|
31
|
+
spec.add_dependency 'multi_xml', '~> 0.6'
|
32
|
+
spec.add_dependency 'faraday_middleware', '~> 0.11'
|
33
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "horizon_client/version"
|
2
|
+
require "faraday"
|
3
|
+
require "multi_xml"
|
4
|
+
require "faraday_middleware"
|
5
|
+
|
6
|
+
module HorizonClient
|
7
|
+
def self.new(*args)
|
8
|
+
Connection.new(*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
class ClientError < Faraday::ClientError
|
12
|
+
def initialize(e)
|
13
|
+
info = e.response ? e.response[:body].fetch('error', {}).fetch('message', '') : ''
|
14
|
+
super [e.message, info].join(': ')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Connection
|
19
|
+
def initialize(url = nil)
|
20
|
+
url ||= ENV['HORIZON_REST_URL']
|
21
|
+
|
22
|
+
@connection = Faraday.new url do |conn|
|
23
|
+
conn.response :raise_error
|
24
|
+
conn.response :xml, :content_type => /\bxml$/
|
25
|
+
|
26
|
+
conn.adapter Faraday.default_adapter
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def url_prefix
|
31
|
+
@connection.url_prefix
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(path = '', params = {})
|
35
|
+
response = @connection.get path, params
|
36
|
+
response.body
|
37
|
+
|
38
|
+
rescue Faraday::ClientError => e
|
39
|
+
raise ClientError.new(e)
|
40
|
+
end
|
41
|
+
|
42
|
+
def post(path = '', body)
|
43
|
+
response = @connection.post do |req|
|
44
|
+
req.url path
|
45
|
+
req.headers['Content-Type'] = 'application/xml;charset=UTF-8'
|
46
|
+
req.body = body
|
47
|
+
end
|
48
|
+
|
49
|
+
response.body
|
50
|
+
rescue Faraday::ClientError => e
|
51
|
+
raise ClientError.new(e)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: horizon_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MAK IT
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.11'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.11'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: multi_xml
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday_middleware
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.11'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.11'
|
111
|
+
description: Client for Horizon by VISMA accounting REST xml API.
|
112
|
+
email:
|
113
|
+
- martins.lapsa@makit.lv
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- bin/console
|
125
|
+
- bin/setup
|
126
|
+
- horizon_client.gemspec
|
127
|
+
- lib/horizon_client.rb
|
128
|
+
- lib/horizon_client/version.rb
|
129
|
+
homepage: http://rubygems.org/gems/horizon_client
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.4.5.1
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Client for Horizon accounting REST xml API.
|
153
|
+
test_files: []
|