promise_pay 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43253e9c2b30e88767979b1467b7fd9ae4c9842b
4
- data.tar.gz: 0938e4da765b8bdc5095949be58041a25e4b50e5
3
+ metadata.gz: a1d35eed99d87f83d0cec327486a4a156db10b28
4
+ data.tar.gz: 670c40d18597dc5da5b66f76682db51cdf28e962
5
5
  SHA512:
6
- metadata.gz: 437490454de825b7a1fa217f66adabb85ce55d39d3ece41a3f7f2177f7b02c94cbb04830dd3df20ff857f9dbc24fb7eb2288621ee4043ff56c1af0c564dd8fba
7
- data.tar.gz: c6819968ba0dba531635a74ed84df14d1c52b1103c0dc90b13412fc9a1350e5ceda6c180f5f394e94080cdb38edc01c9970fc3c5c7c1c69c8e3eeeb5834f6b99
6
+ metadata.gz: c40c8c221466c173af2a14195e843c2ec65c539578ceec3b6128b401bb4d6957b964e966c174b4a3b51fd7f2179b867e51acee8bfede3779ab4444ce5ff77e9c
7
+ data.tar.gz: 50d45d6f1018a1281cef90c6a5b22f998ed5a08cf35480284a7c8688f8d6574c415a6c727f8c0d190039bd418b76826bec46c79162f9a2e2744f29c282504ece
@@ -5,3 +5,4 @@ rvm:
5
5
  - 2.1.1
6
6
  - 2.1.3
7
7
  - 2.1.5
8
+ - 2.2.2
data/README.md CHANGED
@@ -52,12 +52,17 @@ session.token => "8cfd23e3-196e-4a45-ab16-d1213094871e"
52
52
  user = PromisePay::User.find(12345)
53
53
  user.email => "email@addr"
54
54
 
55
+ # Query for a status of an item (abc123) returning a PromisePay::Item::Status object
56
+ user = PromisePay::Item::Status.find('abc123')
57
+ user.state => "pending"
58
+
55
59
  # Query PromisePay for an item (1s345) returning a PromisePay::Item object
56
60
  item = PromisePay::Item.find("1s345")
57
61
  item.amount => 10
62
+ # Note: this is a slow operation, it you just want item status use the Item::Status API
58
63
 
59
64
  # Create a fee returning a PromisePay::Feelist object
60
- fee = PromisePay::Feelst.create(fee_params)
65
+ fee = PromisePay::Feelist.create(fee_params)
61
66
  fee.id => "5c07f36a-d18f-4153-9a75-ebf9f4f2f9ef"
62
67
 
63
68
  ```
@@ -28,7 +28,8 @@ module PromisePay
28
28
  @token ||= (
29
29
  begin
30
30
  marketplace.request_token
31
- rescue PromisePay::RequestError
31
+ rescue Exception => e
32
+ puts e
32
33
  puts "WARNING: token generation failed (Check your credentials)"
33
34
  "token"
34
35
  end
@@ -36,7 +37,9 @@ module PromisePay
36
37
  end
37
38
 
38
39
  def copy_initializer
39
- template "promise_pay_initializer.rb", "config/initializers/promise_pay.rb"
40
+ template \
41
+ "promise_pay_initializer.rb",
42
+ "config/initializers/promise_pay.rb"
40
43
  end
41
44
  end
42
45
  end
@@ -2,4 +2,6 @@ require "promise_pay"
2
2
 
3
3
  PromisePay.api_user = "<%= email %>"
4
4
  PromisePay.api_key = "<%= token %>"
5
+
6
+ # Consider having this read from config
5
7
  PromisePay.env = :<%= env %>
@@ -7,6 +7,7 @@ require "promise_pay/fee"
7
7
  require "promise_pay/version"
8
8
  require "promise_pay/collection"
9
9
  require "promise_pay/country"
10
+ require "promise_pay/item_status"
10
11
 
11
12
  module PromisePay
12
13
  API_HOST = "https://secure.api.promisepay.com/"
@@ -0,0 +1,39 @@
1
+ require "promise_pay/lib/dynamic_accessors"
2
+ require "json"
3
+
4
+ module PromisePay
5
+ class ItemStatus
6
+ include Lib::DynamicAccessors
7
+
8
+ attr_reader :id
9
+
10
+ def initialize(id = nil, options = {})
11
+ @id = id
12
+
13
+ assign_instance_variables({'item' => options})
14
+ end
15
+
16
+ class << self
17
+ def find(id)
18
+ new(id).find
19
+ end
20
+ end
21
+
22
+ def find
23
+ assign_instance_variables(resource_result)
24
+ self
25
+ end
26
+
27
+ private
28
+
29
+ def resource_result
30
+ request = PromisePay::Request.new(path: api_resource)
31
+ response = request.execute
32
+ JSON.parse(response)["items"]
33
+ end
34
+
35
+ def api_resource
36
+ "items/#{id}/status"
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module PromisePay
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe PromisePay::ItemStatus do
4
+ let(:request) { double("PromisePay::Request", execute: sample_response) }
5
+
6
+ before do
7
+ allow(PromisePay::Request).to receive(:new) { request }
8
+ end
9
+
10
+ describe ".find" do
11
+ let(:sample_response) { File.read("./spec/support/fixtures/item_status/find.json") }
12
+ let(:item_id) { "wef9834tg" }
13
+
14
+ it "returns a PromisePay::ItemStatus object" do
15
+ expect(described_class.find(item_id)).to be_a_kind_of PromisePay::ItemStatus
16
+ end
17
+
18
+ it "returned object has correctly assigned attributes" do
19
+ promise_pay_item = described_class.find(item_id)
20
+ expect(promise_pay_item.id).to eq "wef9834tg"
21
+ expect(promise_pay_item.status).to eq 22200
22
+ expect(promise_pay_item.state).to eq "payment_deposited"
23
+ end
24
+
25
+ it "instantiates PromisePay::Request with the correct path" do
26
+ valid_path = "items/#{item_id}/status"
27
+ expect(PromisePay::Request).to receive(:new).with(path: valid_path)
28
+ described_class.find(item_id)
29
+ end
30
+ end
31
+ end
@@ -5,3 +5,4 @@ require "promise_pay/request"
5
5
  require "promise_pay/session"
6
6
  require "promise_pay/user"
7
7
  require "promise_pay/fee"
8
+ require "promise_pay/item_status"
@@ -0,0 +1,7 @@
1
+ {
2
+ "items": {
3
+ "id": "wef9834tg",
4
+ "status": 22200,
5
+ "state": "payment_deposited"
6
+ }
7
+ }
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promise_pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Norton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rest-client
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.7'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.7'
97
97
  description: PromisePay gem for API calls wrapped in Ruby
@@ -101,8 +101,8 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".gitignore"
105
- - ".travis.yml"
104
+ - .gitignore
105
+ - .travis.yml
106
106
  - Gemfile
107
107
  - LICENSE.txt
108
108
  - README.md
@@ -114,6 +114,7 @@ files:
114
114
  - lib/promise_pay/country.rb
115
115
  - lib/promise_pay/fee.rb
116
116
  - lib/promise_pay/item.rb
117
+ - lib/promise_pay/item_status.rb
117
118
  - lib/promise_pay/lib/dynamic_accessors.rb
118
119
  - lib/promise_pay/marketplace.rb
119
120
  - lib/promise_pay/request.rb
@@ -124,6 +125,7 @@ files:
124
125
  - spec/promise_pay/country_spec.rb
125
126
  - spec/promise_pay/fee_spec.rb
126
127
  - spec/promise_pay/item_spec.rb
128
+ - spec/promise_pay/item_status_spec.rb
127
129
  - spec/promise_pay/marketplace_spec.rb
128
130
  - spec/promise_pay/request_spec.rb
129
131
  - spec/promise_pay/session_spec.rb
@@ -132,6 +134,7 @@ files:
132
134
  - spec/support/fixtures/fee/create.json
133
135
  - spec/support/fixtures/item/find.json
134
136
  - spec/support/fixtures/item/find_all.json
137
+ - spec/support/fixtures/item_status/find.json
135
138
  - spec/support/fixtures/token_generation.json
136
139
  - spec/support/fixtures/user/find.json
137
140
  - spec/support/fixtures/user/find_all.json
@@ -145,17 +148,17 @@ require_paths:
145
148
  - lib
146
149
  required_ruby_version: !ruby/object:Gem::Requirement
147
150
  requirements:
148
- - - ">="
151
+ - - '>='
149
152
  - !ruby/object:Gem::Version
150
153
  version: '0'
151
154
  required_rubygems_version: !ruby/object:Gem::Requirement
152
155
  requirements:
153
- - - ">="
156
+ - - '>='
154
157
  - !ruby/object:Gem::Version
155
158
  version: '0'
156
159
  requirements: []
157
160
  rubyforge_project:
158
- rubygems_version: 2.4.6
161
+ rubygems_version: 2.0.14
159
162
  signing_key:
160
163
  specification_version: 4
161
164
  summary: PromisePay gem
@@ -163,6 +166,7 @@ test_files:
163
166
  - spec/promise_pay/country_spec.rb
164
167
  - spec/promise_pay/fee_spec.rb
165
168
  - spec/promise_pay/item_spec.rb
169
+ - spec/promise_pay/item_status_spec.rb
166
170
  - spec/promise_pay/marketplace_spec.rb
167
171
  - spec/promise_pay/request_spec.rb
168
172
  - spec/promise_pay/session_spec.rb
@@ -171,6 +175,7 @@ test_files:
171
175
  - spec/support/fixtures/fee/create.json
172
176
  - spec/support/fixtures/item/find.json
173
177
  - spec/support/fixtures/item/find_all.json
178
+ - spec/support/fixtures/item_status/find.json
174
179
  - spec/support/fixtures/token_generation.json
175
180
  - spec/support/fixtures/user/find.json
176
181
  - spec/support/fixtures/user/find_all.json