wizypay-api-client 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f231d484040d7bc2ae1cf08f4b411ece9d4abab4
4
- data.tar.gz: dfdff5327ad0b6994e10e48c4a661067753a0d7f
3
+ metadata.gz: 0b166c18169b5185bb68e585f7aea196578c7616
4
+ data.tar.gz: acf0e11988a65a550ddb3495b551c966452a6279
5
5
  SHA512:
6
- metadata.gz: 9f49f63f9bd69cac1a3a3f26eda501e804beb8e69abcb92cd5799cbf537ccb8b18301ab6c8724a6d1dc737f35b797b357aec458aa6cd40634109c32e917dad7b
7
- data.tar.gz: cf1196d81d131d6e71ad8c5dc53b8ff903846493c9a519b95b0057c8e4a01111fb8bf21c3df75a0652986e3c0f3cd7cb0eaad82900a31a5c2249d0d50ad3ca24
6
+ metadata.gz: 3c1b900450f63bb2fedcb455173b300b5b9557d75981b6f3603557bbe99f546222bed7636823082181ac466af3fa21918016a0251edede369ef8ad70373a94f4
7
+ data.tar.gz: fe84c6acf4ee8864ef6c4ea10f0af2f5dc93de822c35d40630c227afb4dbce74675defecef9cdff323d520b8dc4fabc81813e69927880db3b163f392d954856e
data/lib/wizypay.rb CHANGED
@@ -15,6 +15,7 @@ require_relative 'wizypay/merchant_category'
15
15
  require_relative 'wizypay/merchant'
16
16
  require_relative 'wizypay/merchant_version'
17
17
  require_relative 'wizypay/beneficiary'
18
+ require_relative 'wizypay/balance_report'
18
19
 
19
20
  module Wizypay
20
21
  def self.setup(api_key, api_secret, api_endpoint = 'https://api.wizypay.com')
@@ -0,0 +1,23 @@
1
+ module Wizypay
2
+ class BalanceReport < Resource
3
+ class Line < Resource
4
+ def date
5
+ return nil unless super.present?
6
+ Date.parse(super)
7
+ end
8
+ end
9
+
10
+ def self.show(granularity, opts = {})
11
+ raw = ApiClient.get('/balance_report', opts.merge(granularity: granularity))
12
+ Collection.new(Line, raw[:data], raw[:meta])
13
+ end
14
+
15
+ def self.monthly(opts = {})
16
+ show('month', opts)
17
+ end
18
+
19
+ def self.daily(opts = {})
20
+ show('day', opts)
21
+ end
22
+ end
23
+ end
@@ -78,6 +78,11 @@ module Wizypay
78
78
  Time.parse(super)
79
79
  end
80
80
 
81
+ def cancelled_at
82
+ return nil unless super.present?
83
+ Time.parse(super)
84
+ end
85
+
81
86
  def operations
82
87
  Collection.new(VdcOperation, super['data'], super['meta'])
83
88
  end
@@ -1,3 +1,3 @@
1
1
  module Wizypay
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ module Wizypay
4
+ RSpec.describe BalanceReport do
5
+ let(:api_key) { 'key' }
6
+ let(:api_secret) { 'secret' }
7
+ let(:api_endpoint) { 'https://api.wizypay.com' }
8
+ let!(:request) { stub_request(:get, "#{api_endpoint}/balance_report?granularity=month").
9
+ with(headers: { 'Accept' => 'application/json',
10
+ 'Authorization' => /WIZYPAY #{api_key}:.*/ }).
11
+ to_return(status: 200, body: '{"data": [{"date": "2016-02-01"}]}') }
12
+ before do
13
+ Wizypay.setup(api_key, api_secret, api_endpoint)
14
+ end
15
+
16
+ describe '.show' do
17
+ it 'returns' do
18
+ response = BalanceReport.show('month')
19
+ expect(request).to have_been_made
20
+ expect(response.length).to eq 1
21
+ expect(response.first).to be_a(BalanceReport::Line)
22
+ expect(response.first.date).to be_a(Date)
23
+ end
24
+ end
25
+
26
+ describe '.monthly' do
27
+ it 'delegates to show' do
28
+ expect(BalanceReport).to receive(:show).with('month', {})
29
+ BalanceReport.monthly
30
+ end
31
+ end
32
+
33
+ describe '.daily' do
34
+ it 'delegates to show' do
35
+ expect(BalanceReport).to receive(:show).with('day', {})
36
+ BalanceReport.daily
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Wizypay
4
- RSpec.describe 'DebitCard#refun' do
4
+ RSpec.describe 'DebitCard#refund' do
5
5
 
6
6
  let(:api_key) { 'key' }
7
7
  let(:api_secret) { 'secret' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wizypay-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chaker Nakhli
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-15 00:00:00.000000000 Z
13
+ date: 2016-02-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: simple-hmac
@@ -152,6 +152,7 @@ files:
152
152
  - lib/wizypay.rb
153
153
  - lib/wizypay/ad.rb
154
154
  - lib/wizypay/api_client.rb
155
+ - lib/wizypay/balance_report.rb
155
156
  - lib/wizypay/beneficiary.rb
156
157
  - lib/wizypay/card_methods.rb
157
158
  - lib/wizypay/collection.rb
@@ -164,6 +165,7 @@ files:
164
165
  - lib/wizypay/resource.rb
165
166
  - lib/wizypay/vdc_operation.rb
166
167
  - lib/wizypay/version.rb
168
+ - spec/balance_report/balance_report_spec.rb
167
169
  - spec/beneficiary/beneficiary_spec.rb
168
170
  - spec/debit_card/cancel_card_spec.rb
169
171
  - spec/debit_card/card_all_spec.rb
@@ -206,6 +208,7 @@ signing_key:
206
208
  specification_version: 4
207
209
  summary: Programmatic API to access Wizypay's API.
208
210
  test_files:
211
+ - spec/balance_report/balance_report_spec.rb
209
212
  - spec/beneficiary/beneficiary_spec.rb
210
213
  - spec/debit_card/cancel_card_spec.rb
211
214
  - spec/debit_card/card_all_spec.rb