pinter 0.1.0 → 0.2.0
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.
- data/Readme.markdown +16 -1
- data/lib/pinter.rb +2 -1
- data/lib/pinter/result.rb +13 -0
- data/lib/pinter/subscription.rb +21 -3
- data/lib/pinter/user.rb +1 -1
- data/lib/pinter/version.rb +1 -1
- metadata +3 -2
data/Readme.markdown
CHANGED
@@ -12,6 +12,7 @@ Get your API key and API secret from [your API page](https://www.pintpay.com/api
|
|
12
12
|
|
13
13
|
Pinter.api_key = "25fdbd9bs0f3sa00f0ecg3e20bja1fag"
|
14
14
|
Pinter.api_secret = "93a76x73afhe4hgbeqd2720e7eetfu19"
|
15
|
+
Pinter.subdomain = "your-subdomain"
|
15
16
|
|
16
17
|
### List all subscriptions
|
17
18
|
|
@@ -25,6 +26,20 @@ Returns the hash of one subscription. Use the subscription's "secret" attribute
|
|
25
26
|
|
26
27
|
Pinter::Subscription.find "23862dc3979f365d"
|
27
28
|
|
29
|
+
You can also find the subscription by your custom identifier.
|
30
|
+
|
31
|
+
Pinter::Subscription.find_by_identifier "231"
|
32
|
+
|
33
|
+
### See your page's URL
|
34
|
+
|
35
|
+
Returns the URL to your PintPay page.
|
36
|
+
|
37
|
+
Pinter.url
|
38
|
+
|
39
|
+
You can also supply the parameters, like the user's email and identifier.
|
40
|
+
|
41
|
+
Pinter.url :email => "user@domain.com", :identifier => "1"
|
42
|
+
|
28
43
|
## Todo
|
29
44
|
|
30
45
|
* Tests.
|
@@ -35,4 +50,4 @@ Returns the hash of one subscription. Use the subscription's "secret" attribute
|
|
35
50
|
|
36
51
|
#### Copyright
|
37
52
|
|
38
|
-
Copyright (c) 2011 Nathan Borgo. See
|
53
|
+
Copyright (c) 2011 Nathan Borgo. See License for details.
|
data/lib/pinter.rb
CHANGED
data/lib/pinter/subscription.rb
CHANGED
@@ -7,7 +7,7 @@ module Pinter
|
|
7
7
|
# default_params :api_key => Pinter.api_key, :api_secret => Pinter.api_secret
|
8
8
|
format :json
|
9
9
|
|
10
|
-
attr_reader :first_name, :last_name, :recurring, :secret, :user, :product, :created_at
|
10
|
+
attr_reader :first_name, :last_name, :recurring, :secret, :user, :product, :identifier, :created_at
|
11
11
|
|
12
12
|
def initialize(attributes)
|
13
13
|
set_instance_variables_from_hash attributes
|
@@ -30,8 +30,26 @@ module Pinter
|
|
30
30
|
|
31
31
|
def self.find(secret)
|
32
32
|
sub = get "/subscriptions/#{secret}", :query => { :api_key => Pinter.api_key, :api_secret => Pinter.api_secret }
|
33
|
-
sub
|
34
|
-
|
33
|
+
sub.parsed_response.to_subscription
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.find_by_identifier(identifier)
|
37
|
+
sub = get "/subscriptions/identifier/#{identifier}", :query => { :api_key => Pinter.api_key,
|
38
|
+
:api_secret => Pinter.api_secret }
|
39
|
+
sub.parsed_response.to_subscription
|
40
|
+
end
|
41
|
+
|
42
|
+
def cancel
|
43
|
+
response = Subscription.put "/subscriptions/#{secret}/cancel", :body => { :api_key => Pinter.api_key, :api_secret => Pinter.api_secret }
|
44
|
+
parsed_response = Crack::JSON.parse response.parsed_response
|
45
|
+
|
46
|
+
if response.headers["status"] == 200
|
47
|
+
attributes = {:success => true, :message => "Cancelled subscription"}
|
48
|
+
else
|
49
|
+
attributes = {:success => false, :message => parsed_response}
|
50
|
+
end
|
51
|
+
|
52
|
+
Pinter::Result.new attributes
|
35
53
|
end
|
36
54
|
|
37
55
|
end
|
data/lib/pinter/user.rb
CHANGED
data/lib/pinter/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: pinter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nathan Borgo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-27 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/pinter/base.rb
|
67
67
|
- lib/pinter/hash.rb
|
68
68
|
- lib/pinter/product.rb
|
69
|
+
- lib/pinter/result.rb
|
69
70
|
- lib/pinter/subscription.rb
|
70
71
|
- lib/pinter/user.rb
|
71
72
|
- lib/pinter/version.rb
|