proxypay 0.1.9 → 0.2.0

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: 84da202c215d66d3871e191eb0a1ead3924a81cf
4
- data.tar.gz: 4eb61628abb3c43b97ba87b9274d55203633268d
3
+ metadata.gz: b0cd0307e3e7edbf491c308363f969c964b9bc66
4
+ data.tar.gz: 96b8c33acbf6227c4ed748af166542c6f5026cfb
5
5
  SHA512:
6
- metadata.gz: 332874d31b499eedfde04910d6eb909caae1b4e0a4ec0969f4d4e392ccdffd0dd3976b21fe5ed125c39657705f9ca0090654f531276062d4adfeea8cad3a431b
7
- data.tar.gz: b2cd27e3a75c3b940168d28ca7373047e7d79e196af87df2a13f5e4a705f504be4b5cf872ae192fb5e4184df0917db4648c1a1b898829272dc8d0ef6eb067287
6
+ metadata.gz: c5789b739a511d2f4bec97f01404a150a0106108885684dc03296c5a5142d86cdda9d486a6abce299a0804f11010078da1e4d066438ebccd2bba8e355ed18934
7
+ data.tar.gz: 4c4bc56b8dba936ac01bbf5f708af2d6f4253a0823bad2508ef88716eab3bc37faeee609bb251aa9d07aa9b42e68738f6f1bd7fcad4894d5ad5efbc3bd999aec
@@ -4,12 +4,33 @@ require "httparty"
4
4
 
5
5
  module Proxypay
6
6
  include HTTParty
7
- base_uri "api.proxypay.co.ao"
7
+ base_uri "https://api.proxypay.co.ao"
8
8
 
9
9
  # Fetch all available references
10
10
  def self.get_references(options={})
11
- options = {:basic_auth => authenticate}
12
- get("/references", options).parsed_response
11
+ # request body and header
12
+ content = {}
13
+ auth = {:basic_auth => authenticate}
14
+ body = {:headers => {'Content-Type' => 'application/json'}}
15
+ content.merge!(auth)
16
+ content.merge!(body)
17
+ # request query options
18
+ options = {limit: 20, offset: 0, status: nil, q: nil}.merge!(options)
19
+ # query options
20
+ case options != nil
21
+ # get refs with provided status w/o specific custom query
22
+ when options.fetch(:status) != nil && options.fetch(:q) == nil
23
+ get("/references?limit=#{options[:limit]}&offset=#{options[:offset]}&status=#{options[:status]}", content).parsed_response
24
+ # get refs with provided custom query with specifc status
25
+ when options.fetch(:status) != nil && options.fetch(:q) != nil
26
+ get("/references?q=#{options[:q]}&limit=#{options[:limit]}&offset=#{options[:offset]}&status=#{options[:status]}", content).parsed_response
27
+ # get refs with provided custom query w/o providing specific status
28
+ when options.fetch(:status) == nil && options.fetch(:q) != nil
29
+ get("/references?q=#{options[:q]}&limit=#{options[:limit]}&offset=#{options[:offset]}", content).parsed_response
30
+ else
31
+ # just get all the reference as per the api defaults (when there is no args provided)
32
+ get("/references", content).parsed_response
33
+ end
13
34
  end
14
35
 
15
36
  # Fetch a specific reference by his ID string
@@ -49,9 +70,23 @@ module Proxypay
49
70
  end
50
71
 
51
72
  # Fetch all availables payments that have not been acknowledged.
52
- def self.get_payments
53
- options = {:basic_auth => authenticate}
54
- get("/events/payments", options).parsed_response
73
+ def self.get_payments(options={})
74
+ # request body and header
75
+ content = {}
76
+ auth = {:basic_auth => authenticate}
77
+ body = {:headers => {'Content-Type' => 'application/json'}}
78
+ content.merge!(auth)
79
+ content.merge!(body)
80
+
81
+ # request query options
82
+ options = {n: nil}.merge!(options)
83
+ if options.fetch(:n) == nil
84
+ # get payments without providing any number(quantity)
85
+ get("/events/payments", content).parsed_response
86
+ else
87
+ # get payments with based on the number(quantity) provided
88
+ get("/events/payments?n=#{options[:n]}", content).parsed_response
89
+ end
55
90
  end
56
91
 
57
92
  # Acknowledge a payment by submitting his ID
@@ -1,3 +1,3 @@
1
1
  module Proxypay
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_development_dependency "bundler", "~> 1.10"
32
32
  spec.add_development_dependency "rake", "~> 10.0"
33
- spec.add_dependency 'httparty', "~> 0.13.7"
33
+ spec.add_dependency "httparty", "~> 0.13.7"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxypay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Maziano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-11 00:00:00.000000000 Z
11
+ date: 2017-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.4.6
95
+ rubygems_version: 2.6.8
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: A Ruby gem for ProxyPay API(https://proxypay.co.ao) made by SmartTechys(http://smarttechys.co.ao)