paidy 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dea43e84c5af80472869c5ec7fb4925fc3ad033082253fdb9d66e4026eb7b254
4
- data.tar.gz: 45783e95eb0eb244f0f2d1d80b824c6169d5b295e436536dd57d023993740642
3
+ metadata.gz: 60b7d42b64dfcec3324ca3cafadc777d1e74182d54ae8569cfb59c3eca7ddedc
4
+ data.tar.gz: 1f0e3bcccbb0057c8bb9b2f964a0a44306850d205391d9e0766e44c327eaf0b8
5
5
  SHA512:
6
- metadata.gz: 40cea4b74d8af4800904f58952a9d6458c51946f9c3720b4330cb66e54e2cd7b5a3821b09dc89a6b83f78b2f5cf5041aff4a95343687ce82ee674e541873efb3
7
- data.tar.gz: 1c0ae8cde96c34d0ef759fcdef96d6f81a49dd622cac6f7502ee04a37c746f2a6de27a6d7d2578be4ca8fc17f70665ba127ba70c8ed7fb610b895a9c53eb5588
6
+ metadata.gz: cce61e83e5a263a032b8c09464c2a0e6a9b938d2f7e6081a8310acea635d86404130d0c58f321fd3ea16f4daa984aba15f7b5f8a0d052d931d2dc40c3bfd00d8
7
+ data.tar.gz: c652a90eb5301997e503bbe6435aa275c7219cc9da2bc2fc0966e6f79f5beec0713796829910b78504ffba8d3721ae9ecbad0df90d98bc01acfa8c2ad97437cc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paidy (0.0.2)
4
+ paidy (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -12,15 +12,15 @@ GEM
12
12
  rspec-core (~> 3.9.0)
13
13
  rspec-expectations (~> 3.9.0)
14
14
  rspec-mocks (~> 3.9.0)
15
- rspec-core (3.9.1)
16
- rspec-support (~> 3.9.1)
17
- rspec-expectations (3.9.1)
15
+ rspec-core (3.9.2)
16
+ rspec-support (~> 3.9.3)
17
+ rspec-expectations (3.9.2)
18
18
  diff-lcs (>= 1.2.0, < 2.0)
19
19
  rspec-support (~> 3.9.0)
20
20
  rspec-mocks (3.9.1)
21
21
  diff-lcs (>= 1.2.0, < 2.0)
22
22
  rspec-support (~> 3.9.0)
23
- rspec-support (3.9.2)
23
+ rspec-support (3.9.3)
24
24
 
25
25
  PLATFORMS
26
26
  ruby
@@ -33,20 +33,22 @@ module Paidy
33
33
  uri = api_uri(path: path)
34
34
 
35
35
  case method.to_s.downcase.to_sym
36
- # when :get
37
- # uri += (URI.parse(uri).query.present? ? '&' : '?') + query_parameter(params)
36
+ when :get
37
+ uri += (uri.query.present? ? '&' : '?') + query_parameter(params) if params.present?
38
+ req = Net::HTTP::Get.new(uri)
38
39
  when :post
39
40
  req = Net::HTTP::Post.new(uri)
40
- req['Content-Type'] = 'application/json'
41
- req['Paidy-Version'] = @api_version
42
- req['Authorization'] = "Bearer #{secret_key}"
43
41
  req.body = params.to_json
44
-
45
- req_options = {
46
- use_ssl: @use_ssl,
47
- }
48
42
  end
49
43
 
44
+ req['Content-Type'] = 'application/json'
45
+ req['Paidy-Version'] = @api_version
46
+ req['Authorization'] = "Bearer #{secret_key}"
47
+
48
+ req_options = {
49
+ use_ssl: @use_ssl,
50
+ }
51
+
50
52
  response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
51
53
  http.request(req)
52
54
  end
@@ -65,9 +67,9 @@ module Paidy
65
67
  def self.query_parameter(params)
66
68
  params.map do |k, v|
67
69
  if v.is_a?(Array)
68
- v.map{ |vv| "#{k}[]=#{CGI.encode(vv)}" }.join('&')
70
+ v.map{ |vv| "#{k}[]=#{CGI.escape(vv)}" }.join('&')
69
71
  else
70
- "#{k}=#{CGI.encode(v)}"
72
+ "#{k}=#{CGI.escape(v)}"
71
73
  end
72
74
  end.join('&')
73
75
  end
@@ -6,6 +6,13 @@ module Paidy
6
6
 
7
7
  self.new(res['id'])
8
8
  end
9
+
10
+ def retrieve(id)
11
+ instance = self.new(id)
12
+ instance.refresh
13
+
14
+ instance
15
+ end
9
16
  end
10
17
 
11
18
  def initialize(id)
@@ -42,6 +49,14 @@ module Paidy
42
49
  end
43
50
  end
44
51
 
52
+ def refresh
53
+ res = Paidy.request(:get, "payments/#{id}")
54
+
55
+ if res['status'] == 'closed' && res['captures'].present?
56
+ @capture_id = res['captures'][0]['id']
57
+ end
58
+ end
59
+
45
60
  private
46
61
 
47
62
  def base_path
@@ -1,3 +1,3 @@
1
1
  module Paidy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - rn0rno
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-04 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler