pinter 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ *.sublime-project
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in pinter.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pinter (0.0.1)
5
+ hashie (>= 1.0.0)
6
+ httparty (>= 0.7.7)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ crack (0.1.8)
12
+ hashie (1.0.0)
13
+ httparty (0.7.7)
14
+ crack (= 0.1.8)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bundler (>= 1.0.0.rc.6)
21
+ pinter!
data/License ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 Nathan Borgo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/Readme.markdown ADDED
@@ -0,0 +1,38 @@
1
+ # Pinter
2
+
3
+ The Ruby [PintPay API](https://www.pintpay.com/api_docs) Gem. PintPay helps collect payments for your app. Now with a Ruby wrapper.
4
+
5
+ ## Install
6
+
7
+ gem install pinter
8
+
9
+ ## Usage
10
+
11
+ Get your API key and API secret from [your API page](https://www.pintpay.com/api_docs).
12
+
13
+ Pinter.api_key = "25fdbd9bs0f3sa00f0ecg3e20bja1fag"
14
+ Pinter.api_secret = "93a76x73afhe4hgbeqd2720e7eetfu19"
15
+
16
+ ### List all subscriptions
17
+
18
+ Returns an array of your subscriptions.
19
+
20
+ Pinter::Subscription.all
21
+
22
+ ### Find specific subscription
23
+
24
+ Returns the hash of one subscription. Use the subscription's "secret" attribute to find it.
25
+
26
+ Pinter::Subscription.find "23862dc3979f365d"
27
+
28
+ ## Todo
29
+
30
+ * Tests.
31
+ * Throw an exception when you forget to set your API key and secret.
32
+ * Refactor the Pinter::Subscription default_params.
33
+ * More tests.
34
+ * Support PintPay's webhooks.
35
+
36
+ #### Copyright
37
+
38
+ Copyright (c) 2011 Nathan Borgo. See LICENSE for details.
@@ -0,0 +1,11 @@
1
+ module Pinter
2
+ module Base
3
+
4
+ def set_instance_variables_from_hash(hash)
5
+ hash.each do |key, value|
6
+ instance_variable_set "@#{key}", value
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ class Hash
2
+
3
+ def to_subscription
4
+ Pinter::Subscription.new self
5
+ end
6
+
7
+ end
@@ -0,0 +1,13 @@
1
+ module Pinter
2
+ class Product
3
+
4
+ include Base
5
+
6
+ attr_reader :name, :price_in_cents, :recurring, :created_at
7
+
8
+ def initialize(attributes)
9
+ set_instance_variables_from_hash attributes
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ module Pinter
2
+ class Subscription
3
+
4
+ include HTTParty
5
+ include Base
6
+ base_uri "http://www.pintpay.com/api/1"
7
+ # default_params :api_key => Pinter.api_key, :api_secret => Pinter.api_secret
8
+ format :json
9
+
10
+ attr_reader :first_name, :last_name, :recurring, :secret, :user, :product, :created_at
11
+
12
+ def initialize(attributes)
13
+ set_instance_variables_from_hash attributes
14
+ @user = Pinter::User.new attributes["user"]
15
+ @product = Pinter::Product.new attributes["product"]
16
+ end
17
+
18
+ def self.all
19
+ collection = []
20
+ raw = get "/subscriptions", :query => { :api_key => Pinter.api_key, :api_secret => Pinter.api_secret }
21
+
22
+ raw.to_a
23
+ raw.each do |attributes|
24
+ obj = Pinter::Subscription.new attributes
25
+ collection << obj
26
+ end
27
+
28
+ return collection
29
+ end
30
+
31
+ def self.find(secret)
32
+ sub = get "/subscriptions/#{secret}", :query => { :api_key => Pinter.api_key, :api_secret => Pinter.api_secret }
33
+ sub = sub.parsed_response
34
+ sub.to_subscription
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ module Pinter
2
+ class User
3
+
4
+ include Base
5
+
6
+ attr_reader :email, :identifier, :name, :created_at
7
+
8
+ def initialize(attributes)
9
+ set_instance_variables_from_hash attributes
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Pinter
2
+ VERSION = "0.0.1"
3
+ end
data/lib/pinter.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+ class APIKeyNotSet < StandardError
5
+
6
+ end
7
+
8
+ class APISecretNotSet < StandardError
9
+
10
+ end
11
+
12
+ module Pinter
13
+ def self.api_key
14
+ # raise APIKeyNotSet if @api_key.nil?
15
+
16
+ @api_key
17
+ end
18
+
19
+ def self.api_key=(api_key)
20
+ @api_key = api_key
21
+ end
22
+
23
+ def self.api_secret
24
+ # raise APISecretNotSet if @api_secret.nil?
25
+
26
+ @api_secret
27
+ end
28
+
29
+ def self.api_secret=(api_secret)
30
+ @api_secret = api_secret
31
+ end
32
+ end
33
+
34
+ require 'pinter/hash'
35
+ require 'pinter/base'
36
+ require 'pinter/subscription'
37
+ require 'pinter/user'
38
+ require 'pinter/product'
data/pinter.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/pinter/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "pinter"
6
+ s.version = Pinter::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Nathan Borgo"]
9
+ s.email = ["nathan@subtractiv.com"]
10
+ s.homepage = "https://github.com/subtractiv/pinter"
11
+ s.summary = "Wrapper for PintPay's API."
12
+ s.description = "A wrapper for PintPay's payment API and webhooks."
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "pinter"
16
+
17
+ s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
18
+
19
+ s.add_dependency 'hashie', '>= 1.0.0'
20
+ s.add_dependency 'httparty', '>= 0.7.7'
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
24
+ s.require_path = 'lib'
25
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pinter
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Nathan Borgo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-24 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.0.rc.6
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.0.0
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: httparty
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.7.7
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ description: A wrapper for PintPay's payment API and webhooks.
50
+ email:
51
+ - nathan@subtractiv.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - .gitignore
60
+ - Gemfile
61
+ - Gemfile.lock
62
+ - License
63
+ - Rakefile
64
+ - Readme.markdown
65
+ - lib/pinter.rb
66
+ - lib/pinter/base.rb
67
+ - lib/pinter/hash.rb
68
+ - lib/pinter/product.rb
69
+ - lib/pinter/subscription.rb
70
+ - lib/pinter/user.rb
71
+ - lib/pinter/version.rb
72
+ - pinter.gemspec
73
+ has_rdoc: true
74
+ homepage: https://github.com/subtractiv/pinter
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options: []
79
+
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.6
94
+ requirements: []
95
+
96
+ rubyforge_project: pinter
97
+ rubygems_version: 1.6.2
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Wrapper for PintPay's API.
101
+ test_files: []
102
+