papapi 0.1.8 → 0.1.9

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: 288492199d0c249dd8a2bcc414453c7333e42341
4
- data.tar.gz: daa0e31c2deb63950acb15902c116c20d84dba98
3
+ metadata.gz: aa63660fb9abf83517ec33f84a2cfbad2e144c7d
4
+ data.tar.gz: b5e866c31eefbff40681bac79180690d6bd938a6
5
5
  SHA512:
6
- metadata.gz: 5e61b8937337b8595a67d4b10a2f81346e459227a371c49ccb81885d0cb7fe5b4e59e8b465dd3dd316f37dc1438a1e3f459b849fc995d5c46b5bb5b04147203f
7
- data.tar.gz: 2a42b4b8e9ea2380bdb499af86cb5cce1f1915f4fa0ad8952e31add0a04e5cc89899b851660799f46c3e3c85b19d8f0fea65014eb607e27a792ef1cb2b31b692
6
+ metadata.gz: 5e6187b9c602bec37e666fbac72aa6324c092573bfe7ad1adcfbf440e0e55e712eaeed93f9647680a04828ebeae0b8609a9bb2a86c04b2773ffe0d2cd9eda3be
7
+ data.tar.gz: ad890652669491ec1d0edcb97511c8d5b8b9cec9b461fb6881c2433d16a3993ab165198214259f39043a4168b938f9e2681b5b48eccfb1a2ada80a76081e2dc1
data/README.md CHANGED
@@ -1,29 +1,39 @@
1
1
  # Papapi
2
2
 
3
- A gem to interface for Post Affiliate Pro API.
3
+ A gem for access to the Post Affiliate Pro API.
4
4
 
5
- # Getting started example
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
 
@@ -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
@@ -90,5 +91,9 @@ module Papapi
90
91
  @update_fields[key.to_sym] = value
91
92
  end
92
93
 
94
+ def to_h
95
+ response ? response.to_h : {}
96
+ end
97
+
93
98
  end
94
99
  end
@@ -22,5 +22,9 @@ module Papapi
22
22
  fields[key.to_sym]
23
23
  end
24
24
 
25
+ def to_h
26
+ fields
27
+ end
28
+
25
29
  end
26
30
  end
@@ -26,5 +26,9 @@ module Papapi
26
26
  yield Hash[*attributes.zip(row).flatten]
27
27
  end
28
28
  end
29
+
30
+ def to_a
31
+ rows
32
+ end
29
33
  end
30
34
  end
@@ -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?
@@ -122,5 +124,9 @@ module Papapi
122
124
  @response ? @response[key.to_sym] : nil
123
125
  end
124
126
 
127
+ def to_h
128
+ response ? response.to_h : {}
129
+ end
130
+
125
131
  end
126
132
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Papapi
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  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.8
4
+ version: 0.1.9
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-05-05 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler