wizypay-api-client 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wizypay.rb +2 -0
- data/lib/wizypay/ad.rb +4 -0
- data/lib/wizypay/collection.rb +1 -1
- data/lib/wizypay/merchant.rb +17 -0
- data/lib/wizypay/merchant_category.rb +4 -0
- data/lib/wizypay/merchant_version.rb +21 -0
- data/lib/wizypay/resource.rb +4 -0
- data/lib/wizypay/version.rb +1 -1
- data/spec/merchant_category/merchant_category_spec.rb +26 -0
- data/spec/merchant_version/merchant_version_spec.rb +50 -0
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fea8329539f0457da4dc96c3fe29b9ba76cdde79
|
4
|
+
data.tar.gz: 7ff679baa52f95b4ffdc3f3686b7b73736f7361b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec8fa60444298cc762f5b34ea9b0ca9e3c5b645332526a946c0f3f6b23f61cf41e2ddb10232804886bd2993e0e7894206735f1532c56a9029fa3781b02bec1b1
|
7
|
+
data.tar.gz: 12f3c0745c3484c2710a24fb39ed629bc3caf0fde5d273c1b1800425cc8f30fe0b7140d2cee345cb60195717ef2fe0054f64a2c8e39589f14f8266ae36d10a25
|
data/lib/wizypay.rb
CHANGED
@@ -9,8 +9,10 @@ require_relative 'wizypay/client'
|
|
9
9
|
require_relative 'wizypay/resource'
|
10
10
|
require_relative 'wizypay/collection'
|
11
11
|
require_relative 'wizypay/card'
|
12
|
+
require_relative 'wizypay/ad'
|
12
13
|
require_relative 'wizypay/merchant_category'
|
13
14
|
require_relative 'wizypay/merchant'
|
15
|
+
require_relative 'wizypay/merchant_version'
|
14
16
|
|
15
17
|
module Wizypay
|
16
18
|
def self.setup(api_key, api_secret, api_endpoint = 'https://api.wizypay.com')
|
data/lib/wizypay/ad.rb
ADDED
data/lib/wizypay/collection.rb
CHANGED
data/lib/wizypay/merchant.rb
CHANGED
@@ -9,12 +9,29 @@ module Wizypay
|
|
9
9
|
where(q)
|
10
10
|
end
|
11
11
|
|
12
|
+
def versions
|
13
|
+
MerchantVersion.for(self)
|
14
|
+
end
|
15
|
+
|
12
16
|
def primary_ad
|
13
17
|
Resource.new(super['data'])
|
14
18
|
end
|
15
19
|
|
20
|
+
def primary_ad_id
|
21
|
+
super || primary_ad.id || ads.first.try(:id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def ads
|
25
|
+
Collection.new(Ad, super['data'], super['meta'])
|
26
|
+
end
|
27
|
+
|
16
28
|
def categories
|
17
29
|
Collection.new(MerchantCategory, super['data'], super['meta'])
|
18
30
|
end
|
31
|
+
|
32
|
+
def network_updated_at
|
33
|
+
return nil unless super.present?
|
34
|
+
Time.parse(super)
|
35
|
+
end
|
19
36
|
end
|
20
37
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Wizypay
|
2
|
+
class MerchantVersion < Resource
|
3
|
+
def self.for(merchant)
|
4
|
+
for_id(merchant.id)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.for_id(merchant_id)
|
8
|
+
raw = Client.get("/merchants/#{merchant_id}/versions")
|
9
|
+
Collection.new(self, raw[:data], raw[:meta])
|
10
|
+
end
|
11
|
+
|
12
|
+
def merchant
|
13
|
+
Merchant.new(super['data'])
|
14
|
+
end
|
15
|
+
|
16
|
+
def created_at
|
17
|
+
return nil unless super.present?
|
18
|
+
Time.parse(super)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/wizypay/resource.rb
CHANGED
data/lib/wizypay/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Wizypay
|
4
|
+
RSpec.describe Merchant 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}/merchant_categories").
|
9
|
+
with(headers: { 'Accept' => 'application/json',
|
10
|
+
'Authorization' => /WIZYPAY #{api_key}:.*/ }) }
|
11
|
+
before do
|
12
|
+
Wizypay.setup(api_key, api_secret, api_endpoint)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.all' do
|
16
|
+
it 'returns' do
|
17
|
+
request.to_return(status: 200, body: '{"data": [{"id": 1}]}')
|
18
|
+
response = MerchantCategory.all
|
19
|
+
expect(request).to have_been_made
|
20
|
+
expect(response.length).to eq 1
|
21
|
+
expect(response.first).to be_a(MerchantCategory)
|
22
|
+
expect(response.first.id).to eq 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Wizypay
|
4
|
+
RSpec.describe Merchant do
|
5
|
+
let(:api_key) { 'key' }
|
6
|
+
let(:api_secret) { 'secret' }
|
7
|
+
let(:api_endpoint) { 'https://api.wizypay.com' }
|
8
|
+
let(:merchant_id) { 91 }
|
9
|
+
let!(:request) { stub_request(:get, "#{api_endpoint}/merchants/#{merchant_id}/versions").
|
10
|
+
with(headers: { 'Accept' => 'application/json',
|
11
|
+
'Authorization' => /WIZYPAY #{api_key}:.*/ }).
|
12
|
+
to_return(status: 200, body: '{"data": [{"merchant": {"data": {"name": "old name"}}}]}') }
|
13
|
+
before do
|
14
|
+
Wizypay.setup(api_key, api_secret, api_endpoint)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.for' do
|
18
|
+
it 'returns' do
|
19
|
+
response = MerchantVersion.for(Merchant.new(id: merchant_id))
|
20
|
+
expect(request).to have_been_made
|
21
|
+
expect(response.length).to eq 1
|
22
|
+
expect(response.first).to be_a(MerchantVersion)
|
23
|
+
expect(response.first.merchant).to be_a(Merchant)
|
24
|
+
expect(response.first.merchant.name).to eq 'old name'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.for_id' do
|
29
|
+
it 'returns' do
|
30
|
+
response = MerchantVersion.for_id(merchant_id)
|
31
|
+
expect(request).to have_been_made
|
32
|
+
expect(response.length).to eq 1
|
33
|
+
expect(response.first).to be_a(MerchantVersion)
|
34
|
+
expect(response.first.merchant).to be_a(Merchant)
|
35
|
+
expect(response.first.merchant.name).to eq 'old name'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'Merchant#versions' do
|
40
|
+
it 'returns' do
|
41
|
+
response = Merchant.new(id: merchant_id).versions
|
42
|
+
expect(request).to have_been_made
|
43
|
+
expect(response.length).to eq 1
|
44
|
+
expect(response.first).to be_a(MerchantVersion)
|
45
|
+
expect(response.first.merchant).to be_a(Merchant)
|
46
|
+
expect(response.first.merchant.name).to eq 'old name'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chaker Nakhli
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '1.0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: activemodel
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '4.2'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '4.2'
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
72
|
name: bundler
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,17 +150,21 @@ files:
|
|
136
150
|
- LICENSE.txt
|
137
151
|
- Rakefile
|
138
152
|
- lib/wizypay.rb
|
153
|
+
- lib/wizypay/ad.rb
|
139
154
|
- lib/wizypay/card.rb
|
140
155
|
- lib/wizypay/client.rb
|
141
156
|
- lib/wizypay/collection.rb
|
142
157
|
- lib/wizypay/merchant.rb
|
143
158
|
- lib/wizypay/merchant_category.rb
|
159
|
+
- lib/wizypay/merchant_version.rb
|
144
160
|
- lib/wizypay/resource.rb
|
145
161
|
- lib/wizypay/version.rb
|
146
162
|
- spec/card/cancel_card_spec.rb
|
147
163
|
- spec/card/card_url_spec.rb
|
148
164
|
- spec/card/create_card_spec.rb
|
149
165
|
- spec/merchant/merchant_spec.rb
|
166
|
+
- spec/merchant_category/merchant_category_spec.rb
|
167
|
+
- spec/merchant_version/merchant_version_spec.rb
|
150
168
|
- spec/spec_helper.rb
|
151
169
|
homepage: http://developers.wizypay.com
|
152
170
|
licenses:
|
@@ -178,4 +196,6 @@ test_files:
|
|
178
196
|
- spec/card/card_url_spec.rb
|
179
197
|
- spec/card/create_card_spec.rb
|
180
198
|
- spec/merchant/merchant_spec.rb
|
199
|
+
- spec/merchant_category/merchant_category_spec.rb
|
200
|
+
- spec/merchant_version/merchant_version_spec.rb
|
181
201
|
- spec/spec_helper.rb
|