ruby_payler 0.1.6 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95d6b8280d572da27cf7569277ce6e1b78d0128e
4
- data.tar.gz: ad9a7479f86150564cf0c157a4fb9025102bebe9
3
+ metadata.gz: 48d857d0652485d9a5747b82108023eb82ab5c10
4
+ data.tar.gz: 01226fb35f2b069659bf8394f1ceaa4cd48f140d
5
5
  SHA512:
6
- metadata.gz: 345ccae51f9393225ed214b2c492a649e824489efc53fc16cd6a56f0fa17ac7692041d3e97d3b2d71f5a0ac8782a209ed4c762cdb4373ee779f25de239c3cfa1
7
- data.tar.gz: 2e96a15877e2970472ac0eac2800cc14f31fc9666d9a613ca81097c333948492d391ce92302af33220ce8bc5e8e176ae1d4ac09ea863b33ee3dd5094efb9cec3
6
+ metadata.gz: aa9998e41aff30995bbef7b7cc3d34e1914f33f9b871543fdc787389795c144ee9753dee51fb2c37a42140a57ce1be65ea23b451cfd164ee923650773eba851a
7
+ data.tar.gz: bdb19616e5d813994bf25f3c1a9cc1b89c88303b4b64c7e27e9cbc253e1e8c25e76959f4fb4fdf5ecde481fe7b21c426cabfcf9cae8d20f4229c1eead5603075
data/README.md CHANGED
@@ -5,6 +5,8 @@ _Not all methods, parameters are implemented. There's an issue about that and I'
5
5
 
6
6
  Documentation for API is here: http://payler.com/docs/acquiring.html
7
7
 
8
+ Documentation for this gem: http://www.rubydoc.info/gems/ruby_payler/
9
+
8
10
  ## Installation
9
11
 
10
12
  Add this line to your application's Gemfile:
@@ -1,9 +1,23 @@
1
1
  module RubyPayler
2
2
  class Error < RuntimeError
3
+ def code
4
+ raise NotImplementedError
5
+ end
6
+
7
+ def message
8
+ raise NotImplementedError
9
+ end
3
10
  end
4
11
 
5
12
  # Faraday errors
6
13
  class FailedRequest < Error
14
+ def code
15
+ 'FailedRequest'
16
+ end
17
+
18
+ def message
19
+ self.to_s
20
+ end
7
21
  end
8
22
 
9
23
  # Response.body contains error
@@ -3,9 +3,9 @@ require 'faraday_middleware'
3
3
 
4
4
  module RubyPayler
5
5
  class Payler
6
- attr_reader :host, :key, :password, :connection
6
+ attr_reader :host, :key, :password
7
7
 
8
- def initialize(host:, key:, password:)
8
+ def initialize(host:, key:, password:, debug: false)
9
9
  @host = host
10
10
  @key = key
11
11
  @password = password
@@ -18,34 +18,14 @@ module RubyPayler
18
18
 
19
19
  f.params
20
20
 
21
- f.response :mashify # 3. mashify parsed JSON
22
- f.response :json # 2. parse JSON
23
- #f.response :logger # 1. log requests to STDOUT
21
+ f.response :mashify # 3. mashify parsed JSON
22
+ f.response :json # 2. parse JSON
23
+ f.response :logger if debug # 1. log requests to STDOUT
24
24
 
25
25
  f.adapter Faraday.default_adapter # make requests with Net::HTTP
26
26
  end
27
27
  end
28
28
 
29
- def remove_nils_from_params!(params)
30
- params.delete_if { |k, v| v.nil? }
31
- end
32
-
33
- def call_payler_api(endpoint, params)
34
- remove_nils_from_params!(params)
35
-
36
- begin
37
- response = connection.post(endpoint, params)
38
- rescue Faraday::Error => e
39
- raise RequestError, e.message
40
- end
41
-
42
- result = response.body
43
- if result.error
44
- raise ResponseWithError, result.error
45
- end
46
- result
47
- end
48
-
49
29
  def start_session(
50
30
  order_id:,
51
31
  type:,
@@ -112,5 +92,31 @@ module RubyPayler
112
92
  amount: amount,
113
93
  })
114
94
  end
115
- end
116
- end
95
+
96
+ private
97
+
98
+ def connection
99
+ @connection
100
+ end
101
+
102
+ def remove_nils_from_params!(params)
103
+ params.delete_if { |k, v| v.nil? }
104
+ end
105
+
106
+ def call_payler_api(endpoint, params)
107
+ remove_nils_from_params!(params)
108
+
109
+ begin
110
+ response = connection.post(endpoint, params)
111
+ rescue Faraday::Error => e
112
+ raise RequestError, e.message
113
+ end
114
+
115
+ result = response.body
116
+ if result.error
117
+ raise ResponseWithError, result.error
118
+ end
119
+ result
120
+ end
121
+ end # class Payler
122
+ end # module RubyPayler
@@ -1,3 +1,3 @@
1
1
  module RubyPayler
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_payler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Vasilyev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-17 00:00:00.000000000 Z
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday