paymium_api 0.0.7 → 0.0.14
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 +5 -5
- data/README.md +11 -35
- data/bin/paymium +8 -0
- data/lib/paymium/client.rb +103 -0
- data/lib/paymium/version.rb +6 -0
- data/lib/paymium.rb +21 -0
- metadata +81 -47
- data/.gitignore +0 -20
- data/.pryrc +0 -7
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -1
- data/lib/paymium/api/client.rb +0 -73
- data/lib/paymium/api/version.rb +0 -5
- data/lib/paymium_api.rb +0 -11
- data/paymium_api.gemspec +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6c025a22cfba6934c4dadaa91a262353dcf6657a9f47ac1f410f235397f46ecd
|
|
4
|
+
data.tar.gz: 7ace61b9ae588bbfdfae827a0d17e352cf746c3036fe7777b26ce3cbe53e6d79
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa9c2e2175d200127f5c041e1df275e6fdf220c5c944bb85af94d9ef3905ea970fd0381e9d097c8f3dfabdd193e4137bb720e3f497b68e82d3942a2a20eabd5e
|
|
7
|
+
data.tar.gz: c2fe63b4b819d5443750492371987cbdb75eaa0cb631b96bf6310cc9a078296f168263924fd93478ac4816b67abfb2168a89b11aac22d64090f79ee5ab7fc26b
|
data/README.md
CHANGED
|
@@ -1,44 +1,20 @@
|
|
|
1
|
-
# Paymium
|
|
1
|
+
# Paymium ruby client [](http://travis-ci.org/Paymium/paymium_gem) [](https://coveralls.io/r/Paymium/paymium_gem?branch=master) [](http://badge.fury.io/rb/paymium)
|
|
2
2
|
|
|
3
|
-
Simple ruby
|
|
4
|
-
|
|
5
|
-
Work in progress
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Add this line to your application's Gemfile:
|
|
10
|
-
|
|
11
|
-
gem 'paymium_api'
|
|
12
|
-
|
|
13
|
-
And then execute:
|
|
14
|
-
|
|
15
|
-
$ bundle
|
|
16
|
-
|
|
17
|
-
Or install it yourself as:
|
|
18
|
-
|
|
19
|
-
$ gem install paymium_api
|
|
3
|
+
Simple ruby wrapper for the [Paymium API](https://paymium.github.io/api-documentation/).
|
|
20
4
|
|
|
21
5
|
## Usage
|
|
22
6
|
|
|
23
7
|
```ruby
|
|
24
|
-
|
|
25
|
-
key: "you api token",
|
|
26
|
-
secret: "your api secret"
|
|
8
|
+
require 'paymium'
|
|
27
9
|
|
|
28
|
-
|
|
10
|
+
paymium = Paymium::Client.new({
|
|
11
|
+
host: 'https://paymium.com/api/v1',
|
|
12
|
+
key: '<api token>',
|
|
13
|
+
secret: '<api secret>'
|
|
14
|
+
})
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
````
|
|
16
|
+
paymium.get('/data/EUR/ticker')
|
|
32
17
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- Dev oAuth api points
|
|
36
|
-
- add delete method for orders's cancelations
|
|
37
|
-
|
|
38
|
-
## Contributing
|
|
18
|
+
paymium.get('/user')
|
|
19
|
+
````
|
|
39
20
|
|
|
40
|
-
1. Fork it ( http://github.com/<my-github-username>/paymium_api/fork )
|
|
41
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
42
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
43
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
44
|
-
5. Create new Pull Request
|
data/bin/paymium
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'openssl'
|
|
3
|
+
require 'base64'
|
|
4
|
+
|
|
5
|
+
module Paymium
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Authenticated connection to the Paymium API
|
|
9
|
+
#
|
|
10
|
+
class Client
|
|
11
|
+
|
|
12
|
+
attr_accessor :config
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Initialize a client
|
|
16
|
+
#
|
|
17
|
+
# @param config [Hash] Symbol-keyed hash of the configuration
|
|
18
|
+
#
|
|
19
|
+
def initialize(config = {})
|
|
20
|
+
@config = config
|
|
21
|
+
@host = URI.parse @config.delete(:host) || Paymium::DEFAULT_HOST
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Issue a GET request against the API
|
|
26
|
+
#
|
|
27
|
+
# @param path [String] The request path
|
|
28
|
+
# @param params [Hash] The request parameters
|
|
29
|
+
#
|
|
30
|
+
def get(path, params = {}, &block)
|
|
31
|
+
uri = uri_from_path(path)
|
|
32
|
+
uri.query = URI.encode_www_form params unless params.empty?
|
|
33
|
+
request(Net::HTTP::Get.new(uri), &block)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Issue a POST request against the API
|
|
38
|
+
#
|
|
39
|
+
# @param path [String] The request path
|
|
40
|
+
# @param params [Hash] The request parameters
|
|
41
|
+
#
|
|
42
|
+
def post(path, params = {}, &block)
|
|
43
|
+
req = Net::HTTP::Post.new(uri_from_path(path))
|
|
44
|
+
req.body = Oj.dump(params)
|
|
45
|
+
request(req, &block)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# Issue a DELETE request against the API
|
|
50
|
+
#
|
|
51
|
+
# @param path [String] The request path
|
|
52
|
+
# @param params [Hash] The request parameters
|
|
53
|
+
#
|
|
54
|
+
def delete(path, params = {}, &block)
|
|
55
|
+
uri = uri_from_path(path)
|
|
56
|
+
uri.query = URI.encode_www_form params unless params.empty?
|
|
57
|
+
request(Net::HTTP::Delete.new(uri), &block)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
def set_header_fields(req)
|
|
63
|
+
key = @config[:key]
|
|
64
|
+
nonce = (Time.now.to_f * 10**6).to_i
|
|
65
|
+
data = [nonce, req.uri.to_s, req.body].compact.join
|
|
66
|
+
sig = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @config[:secret], data).strip
|
|
67
|
+
req.add_field "Api-Key", key
|
|
68
|
+
req.add_field "Api-Nonce", nonce
|
|
69
|
+
req.add_field "Api-Signature", sig
|
|
70
|
+
req
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def uri_from_path(path)
|
|
74
|
+
uri = @host.dup
|
|
75
|
+
uri.path = "#{@host.path}/#{path}".gsub('//','/')
|
|
76
|
+
uri
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def request(req, &block)
|
|
80
|
+
req.content_type = 'application/json'
|
|
81
|
+
set_header_fields(req) if @config[:key] and @config[:secret]
|
|
82
|
+
Net::HTTP.start(@host.host, @host.port, :use_ssl => @host.scheme == 'https') do |http|
|
|
83
|
+
resp = http.request(req)
|
|
84
|
+
handle_response(resp, &block)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def handle_response(resp, &block)
|
|
89
|
+
if resp.class == Net::HTTPNoContent
|
|
90
|
+
block.nil? ? nil : block.call(resp)
|
|
91
|
+
elsif resp.class < Net::HTTPSuccess
|
|
92
|
+
parsed_resp = Oj.load(resp.body)
|
|
93
|
+
block.nil? ? parsed_resp : block.call(resp)
|
|
94
|
+
else
|
|
95
|
+
raise Error, resp.body
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Generic Error class
|
|
100
|
+
class Error < RuntimeError; end
|
|
101
|
+
|
|
102
|
+
end
|
|
103
|
+
end
|
data/lib/paymium.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'oj'
|
|
2
|
+
|
|
3
|
+
Oj.default_options = {
|
|
4
|
+
bigdecimal_load: true,
|
|
5
|
+
bigdecimal_as_decimal: true,
|
|
6
|
+
mode: :compat
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
require 'paymium/client'
|
|
10
|
+
require 'paymium/version'
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# Root module
|
|
14
|
+
#
|
|
15
|
+
module Paymium
|
|
16
|
+
|
|
17
|
+
# Default API host
|
|
18
|
+
DEFAULT_HOST = 'https://paymium.com/api/v1'
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
metadata
CHANGED
|
@@ -1,125 +1,159 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: paymium_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
autorequire:
|
|
7
|
+
- Paymium Tech
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: oj
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- -
|
|
16
|
+
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
18
|
version: '0'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- -
|
|
23
|
+
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: rake
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- -
|
|
30
|
+
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
32
|
version: '0'
|
|
34
|
-
type: :
|
|
33
|
+
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- -
|
|
37
|
+
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: rspec
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
|
-
- - ~>
|
|
44
|
+
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '3'
|
|
48
47
|
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
|
-
- - ~>
|
|
51
|
+
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
53
|
+
version: '3'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
55
|
+
name: simplecov
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
|
-
- -
|
|
58
|
+
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
60
|
+
version: 0.16.1
|
|
62
61
|
type: :development
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
|
-
- -
|
|
65
|
+
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
67
|
+
version: 0.16.1
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
69
|
+
name: yard
|
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
|
73
|
-
- -
|
|
72
|
+
- - "~>"
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
74
|
+
version: 0.9.20
|
|
76
75
|
type: :development
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
|
-
- -
|
|
79
|
+
- - "~>"
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
83
|
-
|
|
81
|
+
version: 0.9.20
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: coveralls
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: 0.8.23
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: 0.8.23
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: vcr
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: 6.3.1
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 6.3.1
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: webmock
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '3'
|
|
117
|
+
type: :development
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '3'
|
|
124
|
+
description: The client handles authentication and enables users to directly issue
|
|
125
|
+
requests to the Paymium API
|
|
84
126
|
email:
|
|
85
|
-
-
|
|
86
|
-
executables:
|
|
127
|
+
- tech@paymium.com
|
|
128
|
+
executables:
|
|
129
|
+
- paymium
|
|
87
130
|
extensions: []
|
|
88
131
|
extra_rdoc_files: []
|
|
89
132
|
files:
|
|
90
|
-
- .gitignore
|
|
91
|
-
- .pryrc
|
|
92
|
-
- Gemfile
|
|
93
|
-
- LICENSE.txt
|
|
94
133
|
- README.md
|
|
95
|
-
-
|
|
96
|
-
- lib/paymium
|
|
97
|
-
- lib/paymium/
|
|
98
|
-
- lib/
|
|
99
|
-
|
|
100
|
-
homepage: ''
|
|
134
|
+
- bin/paymium
|
|
135
|
+
- lib/paymium.rb
|
|
136
|
+
- lib/paymium/client.rb
|
|
137
|
+
- lib/paymium/version.rb
|
|
138
|
+
homepage: https://paymium.com
|
|
101
139
|
licenses:
|
|
102
140
|
- MIT
|
|
103
141
|
metadata: {}
|
|
104
|
-
post_install_message:
|
|
105
142
|
rdoc_options: []
|
|
106
143
|
require_paths:
|
|
107
144
|
- lib
|
|
108
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
146
|
requirements:
|
|
110
|
-
- -
|
|
147
|
+
- - ">="
|
|
111
148
|
- !ruby/object:Gem::Version
|
|
112
|
-
version:
|
|
149
|
+
version: 3.2.0
|
|
113
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
151
|
requirements:
|
|
115
|
-
- -
|
|
152
|
+
- - ">="
|
|
116
153
|
- !ruby/object:Gem::Version
|
|
117
154
|
version: '0'
|
|
118
155
|
requirements: []
|
|
119
|
-
|
|
120
|
-
rubygems_version: 2.2.2
|
|
121
|
-
signing_key:
|
|
156
|
+
rubygems_version: 3.6.7
|
|
122
157
|
specification_version: 4
|
|
123
158
|
summary: Paymium API client
|
|
124
159
|
test_files: []
|
|
125
|
-
has_rdoc:
|
data/.gitignore
DELETED
data/.pryrc
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2014 itkin
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
data/lib/paymium/api/client.rb
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
require 'active_support/hash_with_indifferent_access'
|
|
2
|
-
require 'active_support/core_ext/object/blank'
|
|
3
|
-
require 'net/http'
|
|
4
|
-
|
|
5
|
-
require 'openssl'
|
|
6
|
-
require 'base64'
|
|
7
|
-
|
|
8
|
-
module Paymium
|
|
9
|
-
module Api
|
|
10
|
-
class Client
|
|
11
|
-
|
|
12
|
-
def initialize config = {}
|
|
13
|
-
@config = HashWithIndifferentAccess.new config
|
|
14
|
-
@host = URI.parse @config.delete(:host)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def get path, params = {}, &block
|
|
18
|
-
uri = uri_from_path(path)
|
|
19
|
-
uri.query = URI.encode_www_form params unless params.empty?
|
|
20
|
-
request Net::HTTP::Get.new(uri), &block
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def post path, params = {}, &block
|
|
24
|
-
req = Net::HTTP::Post.new(uri_from_path(path))
|
|
25
|
-
req.body = Oj.dump(params)
|
|
26
|
-
request req, &block
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
def set_header_fields req
|
|
33
|
-
key = @config[:key]
|
|
34
|
-
nonce = (Time.now.to_f * 10**6).to_i
|
|
35
|
-
data = [nonce, req.uri.to_s, req.body].compact.join
|
|
36
|
-
sig = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @config[:secret], data).strip
|
|
37
|
-
req.add_field "Api-Key", key
|
|
38
|
-
req.add_field "Api-Nonce", nonce
|
|
39
|
-
req.add_field "Api-Signature", sig
|
|
40
|
-
req
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def uri_from_path path
|
|
44
|
-
uri = @host.dup
|
|
45
|
-
uri.path = "#{@host.path}/#{path}".gsub('//','/')
|
|
46
|
-
uri
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def request req, &block
|
|
50
|
-
req.content_type = 'application/json'
|
|
51
|
-
set_header_fields(req) if @config[:key].present? and @config[:secret].present?
|
|
52
|
-
Net::HTTP.start(@host.host, @host.port, :use_ssl => @host.scheme == 'https') do |http|
|
|
53
|
-
resp = http.request req
|
|
54
|
-
handle_response resp, &block
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
#todo use Oj to parse response to handle big decimal
|
|
59
|
-
def handle_response resp, &block
|
|
60
|
-
if resp.class < Net::HTTPSuccess
|
|
61
|
-
resp = Oj.load(resp.body)
|
|
62
|
-
block.nil? ? resp : block.call(resp)
|
|
63
|
-
else
|
|
64
|
-
raise Error, resp.message
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
class Error < RuntimeError; end
|
|
69
|
-
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
data/lib/paymium/api/version.rb
DELETED
data/lib/paymium_api.rb
DELETED
data/paymium_api.gemspec
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'paymium/api/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = "paymium_api"
|
|
8
|
-
spec.version = Paymium::Api::VERSION
|
|
9
|
-
spec.authors = ["itkin"]
|
|
10
|
-
spec.email = ["nicolas.papon@webflows.fr"]
|
|
11
|
-
spec.summary = %q{Paymium API client}
|
|
12
|
-
spec.description = %q{Paymium API client}
|
|
13
|
-
spec.homepage = ""
|
|
14
|
-
spec.license = "MIT"
|
|
15
|
-
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
-
spec.require_paths = ["lib"]
|
|
20
|
-
spec.required_ruby_version = '~> 2.0'
|
|
21
|
-
|
|
22
|
-
spec.add_dependency 'activesupport'
|
|
23
|
-
spec.add_dependency 'oj'
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.5"
|
|
25
|
-
spec.add_development_dependency "rake"
|
|
26
|
-
spec.add_development_dependency "pry"
|
|
27
|
-
end
|