papapi 0.1.6 → 0.1.7
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 +4 -4
- data/lib/papapi/affiliate.rb +18 -3
- data/lib/papapi/grid_response.rb +6 -0
- data/lib/papapi/merchant.rb +15 -4
- data/lib/papapi/version.rb +1 -1
- data/spec/affiliate_spec.rb +10 -0
- data/spec/merchant_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba0680e86df3b482fad2cc37335b613a5ab72654
|
|
4
|
+
data.tar.gz: 0528020605432d2f6646b0a0a816a7aac9fc5507
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 91d7f5553d326427ba370c1488944ee23a2510f942286a5150cc3303cc3ecffbb91cac03c0aa086da1b252ea7cc23439b737792ffa85474f2f93889357475f97
|
|
7
|
+
data.tar.gz: c887130ee1303121b9380760f9f358a5b7b3be856dfcaa0173ff6ce0c1d02c8ce7c26d7ee4810d143a551c692e3e4a77e1086957d0ca50dbaefc8e00473cd9e5
|
data/lib/papapi/affiliate.rb
CHANGED
|
@@ -5,18 +5,33 @@ module Papapi
|
|
|
5
5
|
|
|
6
6
|
def initialize(session, response = nil)
|
|
7
7
|
@session = session
|
|
8
|
-
|
|
8
|
+
if @session.is_affiliate?
|
|
9
|
+
@class = 'Pap_Affiliates_Profile_PersonalDetailsForm'
|
|
10
|
+
else
|
|
11
|
+
@class = 'Pap_Signup_AffiliateForm'
|
|
12
|
+
end
|
|
9
13
|
@response = response
|
|
14
|
+
@user_id = nil
|
|
10
15
|
end
|
|
11
16
|
|
|
12
17
|
def load
|
|
13
|
-
request = Papapi::FormRequest.new(
|
|
18
|
+
request = Papapi::FormRequest.new(@class, 'load', @session)
|
|
19
|
+
|
|
20
|
+
unless @user_id.nil?
|
|
21
|
+
request.set_field("Id", @user_id)
|
|
22
|
+
request.set_field("userid", @user_id)
|
|
23
|
+
end
|
|
24
|
+
|
|
14
25
|
@response = request.send
|
|
15
26
|
self
|
|
16
27
|
end
|
|
17
28
|
|
|
18
29
|
def id
|
|
19
|
-
@response ? @response[:userid] :
|
|
30
|
+
@response ? @response[:userid] : @user_id
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def id=(user_id)
|
|
34
|
+
@user_id = user_id
|
|
20
35
|
end
|
|
21
36
|
|
|
22
37
|
def [] (key)
|
data/lib/papapi/grid_response.rb
CHANGED
|
@@ -15,6 +15,12 @@ module Papapi
|
|
|
15
15
|
parsed['rows'].slice(1, parsed['rows'].count-1)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
def [] (key)
|
|
19
|
+
if rows[key.to_i]
|
|
20
|
+
return Hash[*attributes.zip(rows[key.to_i]).flatten]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
18
24
|
def each
|
|
19
25
|
rows.each do |row|
|
|
20
26
|
yield Hash[*attributes.zip(row).flatten]
|
data/lib/papapi/merchant.rb
CHANGED
|
@@ -32,10 +32,6 @@ module Papapi
|
|
|
32
32
|
request.set_fields(request_fields)
|
|
33
33
|
response = request.send
|
|
34
34
|
response
|
|
35
|
-
#affiliate = Papapi::Affiliate.new(Papapi::Session.new(@session.url).
|
|
36
|
-
# login(request_fields[:username], request_fields[:rpassword], Papapi::Session::AFFILIATE))
|
|
37
|
-
#affiliate.load
|
|
38
|
-
#affiliate
|
|
39
35
|
end
|
|
40
36
|
|
|
41
37
|
def remove_affiliate(affiliate_id)
|
|
@@ -103,6 +99,21 @@ module Papapi
|
|
|
103
99
|
affiliates
|
|
104
100
|
end
|
|
105
101
|
|
|
102
|
+
def affiliate_by_username(username)
|
|
103
|
+
request = Papapi::GridRequest.new("Pap_Merchants_User_AffiliatesGridSimple", "getRows", @session)
|
|
104
|
+
request.add_filter('username', Papapi::Filter::EQUALS, username)
|
|
105
|
+
|
|
106
|
+
response = request.send
|
|
107
|
+
if response.count > 0
|
|
108
|
+
user = response[0]
|
|
109
|
+
affiliate = Papapi::Affiliate.new(@session)
|
|
110
|
+
affiliate.id = user['userid']
|
|
111
|
+
affiliate.load
|
|
112
|
+
return affiliate
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
|
|
106
117
|
def id
|
|
107
118
|
@response ? @response[:authid] : nil
|
|
108
119
|
end
|
data/lib/papapi/version.rb
CHANGED
data/spec/affiliate_spec.rb
CHANGED
|
@@ -9,4 +9,14 @@ RSpec.describe Papapi::Affiliate::Commission do
|
|
|
9
9
|
expect(affiliate.id).to eq('11111111')
|
|
10
10
|
expect(affiliate[:username]).to eq('affiliate@example.com')
|
|
11
11
|
end
|
|
12
|
+
|
|
13
|
+
it "#load - by merchant session" do
|
|
14
|
+
session = Papapi::Session.new(script_url).login(merchant_login, merchant_password)
|
|
15
|
+
affiliate = Papapi::Affiliate.new(session)
|
|
16
|
+
affiliate.id = '11111111'
|
|
17
|
+
affiliate.load()
|
|
18
|
+
expect(affiliate.id).to eq('11111111')
|
|
19
|
+
expect(affiliate[:username]).to eq('affiliate@example.com')
|
|
20
|
+
end
|
|
21
|
+
|
|
12
22
|
end
|
data/spec/merchant_spec.rb
CHANGED
|
@@ -57,4 +57,15 @@ RSpec.describe Papapi::Affiliate::Commission do
|
|
|
57
57
|
expect(affiliates[0]['username']).to eq('affiliate@example.com')
|
|
58
58
|
|
|
59
59
|
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
it "#affiliate_by_username" do
|
|
63
|
+
session = Papapi::Session.new(script_url).login(merchant_login, merchant_password)
|
|
64
|
+
merchant = Papapi::Merchant.new(session)
|
|
65
|
+
|
|
66
|
+
affiliate = merchant.affiliate_by_username('affiliate@example.com')
|
|
67
|
+
|
|
68
|
+
expect(affiliate[:username]).to eq('affiliate@example.com')
|
|
69
|
+
expect(affiliate.id).to eq('11111111')
|
|
70
|
+
end
|
|
60
71
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: papapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Nizovtsev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-04-
|
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|