papapi 0.1.8 → 0.1.12
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 +5 -5
- data/README.md +18 -8
- data/lib/papapi/affiliate.rb +15 -0
- data/lib/papapi/form_response.rb +4 -0
- data/lib/papapi/grid_response.rb +4 -0
- data/lib/papapi/merchant.rb +8 -1
- data/lib/papapi/merchant_commision.rb +15 -0
- data/lib/papapi/response.rb +10 -1
- data/lib/papapi/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 36e290733745ed22b1679f2707505cdd3ef5375696359651886c9ddd89237f4b
|
|
4
|
+
data.tar.gz: bf7cbec14524a03978edcdfa430573fcded14efee93f325f2ae3b14039910277
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5623ea7f855da1bc17cbbfbbc4431c90c834f10a59c74a638c1b492e8351b55d7f75069be487314e8671ede2790601bb082ad9760a7c14d63dc5cc8ab8bfca7e
|
|
7
|
+
data.tar.gz: 81d225e8cc0120126d78fa074b1b58261ce713fc8a594ce006e5cb0b5534bd13d5bb2968af9a72e889d054fd94b55ab6150216c4b4cf394982006d18752039e7
|
data/README.md
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
# Papapi
|
|
2
2
|
|
|
3
|
-
A gem to
|
|
3
|
+
A gem for access to the Post Affiliate Pro API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Getting started example
|
|
6
6
|
|
|
7
|
-
Create session as merchant
|
|
8
|
-
|
|
7
|
+
###Create session as merchant
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
9
10
|
session = new Papapi::Session("http://demo.postaffiliatepro.com/scripts/server.php");
|
|
10
11
|
session.login("merchant@example.com", "demo")
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
Create session as affiliate in debug mode
|
|
14
|
-
|
|
14
|
+
###Create session as affiliate in debug mode
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
15
17
|
session = new Papapi::Session("http://demo.postaffiliatepro.com/scripts/server.php",true);
|
|
16
18
|
session.login("affiliate@example.com", "demo")
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
Get information about affiliate
|
|
21
|
+
###Get information about affiliate
|
|
20
22
|
|
|
21
|
-
```
|
|
23
|
+
```ruby
|
|
22
24
|
affiliate = Papapi::Affiliate.new(session)
|
|
23
25
|
affiliate.load()
|
|
24
26
|
affiliate[:username]
|
|
25
27
|
```
|
|
26
28
|
|
|
29
|
+
###Get information about merchant
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
merchant = Papapi::Merchant.new(session)
|
|
33
|
+
merchant.load()
|
|
34
|
+
merchant[:username]
|
|
35
|
+
```
|
|
36
|
+
|
|
27
37
|
More documentation, and examples can be found [there](https://support.qualityunit.com/712031-API)
|
|
28
38
|
|
|
29
39
|
|
data/lib/papapi/affiliate.rb
CHANGED
|
@@ -11,6 +11,7 @@ module Papapi
|
|
|
11
11
|
|
|
12
12
|
M_ALLOWED_FIELDS = [:parentuserid, :rstatus, :agreeWithTerms] | A_ALLOWED_FIELDS
|
|
13
13
|
|
|
14
|
+
attr_accessor :response
|
|
14
15
|
|
|
15
16
|
def initialize(session, response = nil)
|
|
16
17
|
@session = session
|
|
@@ -73,6 +74,16 @@ module Papapi
|
|
|
73
74
|
@response ? @response[:userid] : @user_id
|
|
74
75
|
end
|
|
75
76
|
|
|
77
|
+
def getLoginKey
|
|
78
|
+
raise "Merchant session is required" if @session.is_affiliate?
|
|
79
|
+
|
|
80
|
+
request = Papapi::FormRequest.new('Pap_Auth_LoginKeyService', 'getLoginKey', @session)
|
|
81
|
+
request.set_param("userId", self.id)
|
|
82
|
+
|
|
83
|
+
response = request.send
|
|
84
|
+
|
|
85
|
+
return response[:LoginKey]
|
|
86
|
+
end
|
|
76
87
|
|
|
77
88
|
def id=(user_id)
|
|
78
89
|
@user_id = user_id
|
|
@@ -90,5 +101,9 @@ module Papapi
|
|
|
90
101
|
@update_fields[key.to_sym] = value
|
|
91
102
|
end
|
|
92
103
|
|
|
104
|
+
def to_h
|
|
105
|
+
response ? response.to_h : {}
|
|
106
|
+
end
|
|
107
|
+
|
|
93
108
|
end
|
|
94
109
|
end
|
data/lib/papapi/form_response.rb
CHANGED
data/lib/papapi/grid_response.rb
CHANGED
data/lib/papapi/merchant.rb
CHANGED
|
@@ -16,6 +16,8 @@ module Papapi
|
|
|
16
16
|
:phone => :data8
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
attr_accessor :response
|
|
20
|
+
|
|
19
21
|
def initialize(session, response = nil)
|
|
20
22
|
@session = session
|
|
21
23
|
raise "Merchant session is required" if !@session.is_merchant?
|
|
@@ -106,8 +108,9 @@ module Papapi
|
|
|
106
108
|
response = request.send
|
|
107
109
|
if response.count > 0
|
|
108
110
|
user = response[0]
|
|
111
|
+
p user['id']
|
|
109
112
|
affiliate = Papapi::Affiliate.new(@session)
|
|
110
|
-
affiliate.id = user['userid']
|
|
113
|
+
affiliate.id = user['userid'] || user['id']
|
|
111
114
|
affiliate.load
|
|
112
115
|
return affiliate
|
|
113
116
|
end
|
|
@@ -122,5 +125,9 @@ module Papapi
|
|
|
122
125
|
@response ? @response[key.to_sym] : nil
|
|
123
126
|
end
|
|
124
127
|
|
|
128
|
+
def to_h
|
|
129
|
+
response ? response.to_h : {}
|
|
130
|
+
end
|
|
131
|
+
|
|
125
132
|
end
|
|
126
133
|
end
|
|
@@ -48,6 +48,21 @@ module Papapi
|
|
|
48
48
|
r.send
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
#commtypeid Can be found in Merchant panel: Campaigns -> Campaign manager -> edit campaign (pencil icon) -> Commission settings
|
|
52
|
+
def create_raw(affiliate_id, campaign_id, commtypeid, multitier, fields = {})
|
|
53
|
+
r = FormRequest.new('Pap_Merchants_Transaction_TransactionsForm', 'add', @session)
|
|
54
|
+
f = {
|
|
55
|
+
:userid => affiliate_id,
|
|
56
|
+
:campaignid => campaign_id,
|
|
57
|
+
:commtypeid => commtypeid,
|
|
58
|
+
:multiTier => multitier,
|
|
59
|
+
:transid => nil,
|
|
60
|
+
:Id => nil
|
|
61
|
+
}.merge(fields)
|
|
62
|
+
r.set_fields(f)
|
|
63
|
+
r.send
|
|
64
|
+
end
|
|
65
|
+
|
|
51
66
|
def remove(commission_ids)
|
|
52
67
|
#{"C":"Pap_Merchants_Transaction_TransactionsForm", "M":"deleteRows", "ids":["00a47a09"]
|
|
53
68
|
r = Request.new('Pap_Merchants_Transaction_TransactionsForm', 'deleteRows', @session)
|
data/lib/papapi/response.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module Papapi
|
|
2
2
|
class Response
|
|
3
|
-
|
|
4
3
|
REMOVE_VARS = ['name', 'correspondsApi', 'language']
|
|
5
4
|
|
|
6
5
|
attr_reader :responses
|
|
6
|
+
attr_reader :request
|
|
7
7
|
|
|
8
8
|
def initialize (http_response, request)
|
|
9
9
|
@http_response = http_response
|
|
@@ -29,6 +29,15 @@ module Papapi
|
|
|
29
29
|
@parsed
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def to_h
|
|
33
|
+
h = {}
|
|
34
|
+
parsed.each_with_index do |p, index|
|
|
35
|
+
next if index == 0
|
|
36
|
+
h[p[0].to_sym] = p[1]
|
|
37
|
+
end
|
|
38
|
+
h
|
|
39
|
+
end
|
|
40
|
+
|
|
32
41
|
private
|
|
33
42
|
|
|
34
43
|
def check_for_errors
|
data/lib/papapi/version.rb
CHANGED
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.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Nizovtsev
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -94,7 +94,7 @@ homepage: https://github.com/JSBizon/papapi
|
|
|
94
94
|
licenses:
|
|
95
95
|
- MIT
|
|
96
96
|
metadata: {}
|
|
97
|
-
post_install_message:
|
|
97
|
+
post_install_message:
|
|
98
98
|
rdoc_options: []
|
|
99
99
|
require_paths:
|
|
100
100
|
- lib
|
|
@@ -109,9 +109,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
requirements: []
|
|
112
|
-
rubyforge_project:
|
|
113
|
-
rubygems_version: 2.
|
|
114
|
-
signing_key:
|
|
112
|
+
rubyforge_project:
|
|
113
|
+
rubygems_version: 2.7.11
|
|
114
|
+
signing_key:
|
|
115
115
|
specification_version: 4
|
|
116
116
|
summary: A client for the Post Affiliate Pro API
|
|
117
117
|
test_files:
|