quickpay-ruby-client 1.0.0 → 1.0.1
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 +4 -4
- data/README.md +4 -4
- data/lib/quickpay/api/request.rb +45 -42
- data/lib/quickpay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03abde0062db5a1af9085fb988c7a7be2d6afa7f
|
4
|
+
data.tar.gz: dba88591da33e971a544ea2e117ed2dd9b4ffcdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34a6e175531d5abf8dcbd0a5fac90a013e0e66aa4e079d68674f226e3ed1357ca81179df2bd8beec38c73274a0f11af21b15c00502416a6143a3fe701ffe69ca
|
7
|
+
data.tar.gz: ca25a3ca07fe69f35eed2959e39687945fa8ae0baad062446bdbfc255c08c027e423f71a7c8d16f7362f56c0e9c31d35335e0d2d1405550fc812bba0163458e2
|
data/README.md
CHANGED
@@ -61,8 +61,8 @@ client = Quickpay::API::Client.new({ email: ENV['QUICKPAY_LOGIN'], password: ENV
|
|
61
61
|
You can afterwards call any method described in QuickPay api with corresponding http method and endpoint. These methods are supported currently: `get`, `post`, `put`, `patch` and `delete`.
|
62
62
|
|
63
63
|
```
|
64
|
-
client.get("/
|
65
|
-
puts activity
|
64
|
+
client.get("/activity").each do |activity|
|
65
|
+
puts activity["id"]
|
66
66
|
end
|
67
67
|
|
68
68
|
```
|
@@ -70,11 +70,11 @@ end
|
|
70
70
|
If you want raw http response, headers Please add `:raw => true` parameter:
|
71
71
|
|
72
72
|
```
|
73
|
-
status, body, headers = client.get("/
|
73
|
+
status, body, headers = client.get("/activity", :raw => true)
|
74
74
|
|
75
75
|
if status == 200
|
76
76
|
JSON.parse(body).each do |activity|
|
77
|
-
puts activity
|
77
|
+
puts activity["id"]
|
78
78
|
end
|
79
79
|
else
|
80
80
|
puts "Error: #{body}"
|
data/lib/quickpay/api/request.rb
CHANGED
@@ -3,28 +3,31 @@ module QuickPay
|
|
3
3
|
module API
|
4
4
|
class Request
|
5
5
|
include HTTParty
|
6
|
-
|
6
|
+
|
7
7
|
def initialize (options = {})
|
8
8
|
@secret = options[:secret]
|
9
9
|
self.class.base_uri(options[:base_uri] || BASE_URI)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def request method, path, data = {}
|
13
13
|
raw = data.delete(:raw)
|
14
14
|
req_headers = headers.merge(data.delete(:headers) || {})
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
case method
|
17
|
+
when :get, :delete
|
18
|
+
options = { query: data }
|
19
|
+
when :post, :patch, :put
|
20
|
+
options = { body: data.to_json }
|
21
|
+
req_headers["Content-Type"] = "application/json"
|
22
|
+
else
|
23
|
+
options = {}
|
24
|
+
end
|
25
|
+
|
23
26
|
options = options.merge(:headers => headers.merge(req_headers))
|
24
27
|
QuickPay.logger.debug { "#{method.to_s.upcase} #{base_uri}#{path} #{options}" }
|
25
28
|
create_response(raw, self.class.send(method, path, options))
|
26
29
|
end
|
27
|
-
|
30
|
+
|
28
31
|
def create_response raw, res
|
29
32
|
if raw
|
30
33
|
[res.code, res.body, res.headers]
|
@@ -34,11 +37,11 @@ module QuickPay
|
|
34
37
|
response
|
35
38
|
end
|
36
39
|
end
|
37
|
-
|
40
|
+
|
38
41
|
def raise_error body, status
|
39
42
|
code = API_STATUS_CODES[status].to_s
|
40
43
|
args = [code, status, body]
|
41
|
-
|
44
|
+
|
42
45
|
klass =
|
43
46
|
begin
|
44
47
|
require "quickpay/api/errors/#{code}"
|
@@ -47,41 +50,41 @@ module QuickPay
|
|
47
50
|
rescue LoadError, NameError
|
48
51
|
QuickPay::API::Error
|
49
52
|
end
|
50
|
-
|
53
|
+
|
51
54
|
fail klass.new(*args), error_description(body)
|
52
55
|
end
|
53
|
-
|
56
|
+
|
54
57
|
private
|
55
|
-
|
56
|
-
def base_uri
|
57
|
-
self.class.default_options[:base_uri]
|
58
|
-
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
def headers
|
65
|
-
heads = {
|
66
|
-
'User-Agent' => user_agent,
|
67
|
-
'Accept-Version' => "v#{QuickPay::API_VERSION}"
|
68
|
-
}
|
69
|
-
heads['Authorization'] = "Basic #{authorization}" if @secret != nil
|
70
|
-
heads
|
71
|
-
end
|
59
|
+
def base_uri
|
60
|
+
self.class.default_options[:base_uri]
|
61
|
+
end
|
72
62
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
user_agent
|
63
|
+
def error_description msg
|
64
|
+
msg
|
65
|
+
end
|
66
|
+
|
67
|
+
def headers
|
68
|
+
heads = {
|
69
|
+
'User-Agent' => user_agent,
|
70
|
+
'Accept-Version' => "v#{QuickPay::API_VERSION}"
|
71
|
+
}
|
72
|
+
heads['Authorization'] = "Basic #{authorization}" if @secret != nil
|
73
|
+
heads
|
74
|
+
end
|
75
|
+
|
76
|
+
def user_agent
|
77
|
+
user_agent = "quickpay-ruby-client, v#{QuickPay::VERSION}"
|
78
|
+
user_agent += ", #{RUBY_VERSION}, #{RUBY_PLATFORM}, #{RUBY_PATCHLEVEL}"
|
79
|
+
if defined?(RUBY_ENGINE)
|
80
|
+
user_agent += ", #{RUBY_ENGINE}"
|
80
81
|
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
user_agent
|
83
|
+
end
|
84
|
+
|
85
|
+
def authorization
|
86
|
+
Base64.strict_encode64(@secret)
|
87
|
+
end
|
85
88
|
end
|
86
|
-
end
|
89
|
+
end
|
87
90
|
end
|
data/lib/quickpay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickpay-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- QuickPay Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|