paywhirl 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 376d1b7b6510e2cdaef231ca356713542e67d816084f165be379520e2f586ed3
4
+ data.tar.gz: c5f1e5f20719343ffff47f06e47cf5f53cbbf26adf95d79fcfd73f4330731ae2
5
+ SHA512:
6
+ metadata.gz: f9b4933a52d7d5559d3c60a626a07799dc491ff49c91fb193f7d506c20465e6349cd5e17a5dc6b498bba45310e31d0fd385082eea118fd58cd7169cbbe854241
7
+ data.tar.gz: 38f55728d690522826c2a60fe0d8749e711d811af99520e848b9a1c8db0357be8fcac7250abab54bf7ae27201f5f5d7990af574b18f0aafbbcb6053f97d1cc05
@@ -0,0 +1,2 @@
1
+ *.lock
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in paywhirl.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 leafknight
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # Paywhirl
2
+
3
+ Paywhirl's Ruby API library is provided for developers to easily interface with Paywhirl's servers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'paywhirl'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install paywhirl
20
+
21
+ ## Usage
22
+
23
+ [get your API keys by signing up here](https://app.paywhirl.com/)
24
+
25
+ ```ruby
26
+ require "paywhirl"
27
+
28
+ api_key = "pwpk_xxxxxxxxxxxxxxx"
29
+ api_secret = "pwpsk_xxxxxxxxxxx"
30
+
31
+ paywhirl = PayWhirl.new(api_key, api_secret)
32
+ ```
33
+
34
+ [Full docs](https://api.paywhirl.com)
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/paywhirl/ruby-pwclient
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "paywhirl"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,227 @@
1
+ # PayWhirl API Ruby Library
2
+ #
3
+ # Documentation can be obtained at https://api.paywhirl.com
4
+ #
5
+ # API keys can be obtained at https://app.paywhirl.com/api-keys
6
+ #
7
+ # Example Usage:
8
+ # ==================
9
+ # <your_program>
10
+ # require_relative 'PayWhirl'
11
+ # api_key = '<your_api_key_here>'
12
+ # api_secret = '<your_secret_key_here>'
13
+ # paywhirl = PayWhirl.new(api_key, api_secret)
14
+ # paywhirl.<method>
15
+
16
+
17
+ require 'paywhirl/version'
18
+ require 'json'
19
+ require 'faraday'
20
+
21
+
22
+ class PayWhirl
23
+ def initialize(api_key, api_secret, api_base="https://api.paywhirl.com")
24
+ @api_key = api_key.to_s
25
+ @api_secret = api_secret.to_s
26
+ @api_base = api_base.to_s
27
+ @headers = {:api_key => @api_key, :api_secret => @api_secret}
28
+ end
29
+
30
+
31
+ def get_customers(data = nil)
32
+ return self.get('/customers', data)
33
+ end
34
+
35
+ def get_customer(customer_id = nil)
36
+ cust = "/customer/#{customer_id}"
37
+ return self.get(cust)
38
+ end
39
+
40
+ def create_customer(data = nil)
41
+ return self.post('/create/customer', data)
42
+ end
43
+
44
+ def update_customer(data = nil)
45
+ return self.post('/update/customer', data)
46
+ end
47
+
48
+ def update_answer(data = nil)
49
+ return self.post('/update/answer', data)
50
+ end
51
+
52
+ def get_questions(data = 100)
53
+ if data.respond_to?(:to_i)
54
+ data = {"limit" => data}
55
+ end
56
+ return self.get('/questions', data)
57
+ end
58
+
59
+ def get_answers(data = nil)
60
+ if data.respond_to?(:to_i)
61
+ data = {"customer_id" => data}
62
+ end
63
+ return self.get('/answers', data)
64
+ end
65
+
66
+ def get_plans(data = nil)
67
+ return self.get('/plans', data)
68
+ end
69
+
70
+ def get_plan(customer_id = nil)
71
+ plan = "/plan/#{customer_id}"
72
+ return self.get(plan)
73
+ end
74
+
75
+ def create_plan(data = nil)
76
+ return self.post('/create/plan', data)
77
+ end
78
+
79
+ def update_plan(data = nil)
80
+ return self.post('/update/plan', data)
81
+ end
82
+
83
+ def get_subscriptions(customer_id = nil)
84
+ subs = "/subscriptions/#{customer_id}"
85
+ return self.get(subs)
86
+ end
87
+
88
+ def get_subscription(customer_id = nil)
89
+ sub = "/subscription/#{customer_id}"
90
+ return self.get(sub)
91
+ end
92
+
93
+ def get_subscribers(data = nil)
94
+ return self.get('/subscribers', data)
95
+ end
96
+
97
+ def subscribe_customer(data = nil)
98
+ return self.post('/subscribe/customer', data)
99
+ end
100
+
101
+ def update_subscription(subscription_id = nil, plan_id = nil)
102
+ data = {'subscription_id'=>subscription_id, 'plan_id'=>plan_id}
103
+ return self.post('/update/subscription', data)
104
+ end
105
+
106
+ def unsubscribe_customer(subscription_id = nil)
107
+ data = {'subscription_id'=>subscription_id}
108
+ return self.post('/unsubscribe/customer', data)
109
+ end
110
+
111
+ def get_invoice(customer_id = nil)
112
+ format = "/invoice/#{customer_id}"
113
+ return self.get(format)
114
+ end
115
+
116
+ def get_invoices(customer_id = nil)
117
+ format = "/invoices/#{customer_id}"
118
+ return self.get(format)
119
+ end
120
+
121
+ def get_gateways()
122
+ return self.get('/gateways')
123
+ end
124
+
125
+ def get_gateway(customer_id = nil)
126
+ format = "/gateway/#{customer_id}"
127
+ return self.get(format)
128
+ end
129
+
130
+ def create_charge(data = nil)
131
+ return self.post('/create/charge', data)
132
+ end
133
+
134
+ def get_charge(customer_id = nil)
135
+ format = "/charge/#{customer_id}"
136
+ return self.get(format)
137
+ end
138
+
139
+ def get_card(customer_id = nil)
140
+ format = "/card/#{customer_id}"
141
+ return self.get(format)
142
+ end
143
+
144
+ def get_cards(customer_id = nil)
145
+ format = "/cards/#{customer_id}"
146
+ return self.get(format)
147
+ end
148
+
149
+ def create_card(data = nil)
150
+ return self.post('/create/card', data)
151
+ end
152
+
153
+ def delete_card(customer_id = nil)
154
+ data = {'id'=>customer_id}
155
+ return self.post('/delete/card', data)
156
+ end
157
+
158
+ def get_promos()
159
+ return self.get("/promo")
160
+ end
161
+
162
+ def get_promo(customer_id = nil)
163
+ format = "/promo/#{customer_id}"
164
+ return self.get(format)
165
+ end
166
+
167
+ def create_promo(data = nil)
168
+ return self.post('/create/promo', data)
169
+ end
170
+
171
+ def delete_promo(promo_id = nil)
172
+ data = {'id'=>promo_id}
173
+ return self.post('/delete/promo', data)
174
+ end
175
+
176
+ def get_email_template(customer_id = nil)
177
+ format = "/email/#{customer_id}"
178
+ return self.get(format)
179
+ end
180
+
181
+ def get_account()
182
+ return self.get('/account')
183
+ end
184
+
185
+ def get_stats()
186
+ return self.get('/stats')
187
+ end
188
+
189
+ def get_shipping_rules()
190
+ return self.get("/shipping")
191
+ end
192
+
193
+ def get_shipping_rule(customer_id = nil)
194
+ format = "/shipping/#{customer_id}"
195
+ return self.get(format)
196
+ end
197
+
198
+ def get_tax_rule(customer_id = nil)
199
+ format = "/tax/#{customer_id}"
200
+ return self.get(format)
201
+ end
202
+
203
+ def get_tax_rules()
204
+ return self.get('/tax')
205
+ end
206
+
207
+ def get_multi_auth_token(data = nil)
208
+ return self.post('/multiauth', data)
209
+ end
210
+
211
+ def post(endpoint = nil, params = nil)
212
+ conn = Faraday.new(url: @api_base)
213
+ conn.headers = @headers
214
+ response = conn.post(endpoint, params)
215
+ json_object = JSON.parse(response.body)
216
+ return json_object
217
+ end
218
+
219
+ def get(endpoint = nil, params = nil)
220
+ conn = Faraday.new(url: @api_base)
221
+ conn.headers = @headers
222
+ response = conn.get(endpoint, params)
223
+ json_object = JSON.parse(response.body)
224
+ return json_object
225
+ end
226
+
227
+ end
@@ -0,0 +1,3 @@
1
+ module Paywhirl
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "paywhirl/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "paywhirl"
9
+ spec.version = Paywhirl::VERSION
10
+ spec.authors = ["paywhirl"]
11
+ spec.email = ["megrims@gmail.com"]
12
+
13
+ spec.summary = %q{Paywhirl API library for simplifying interaction with Paywhirl services.}
14
+ spec.homepage = "https://github.com/paywhirl/ruby-pwclient"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ spec.add_runtime_dependency "faraday", "~> 0.13.1"
28
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paywhirl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - paywhirl
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.13.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.13.1
69
+ description:
70
+ email:
71
+ - megrims@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - lib/paywhirl.rb
84
+ - lib/paywhirl/version.rb
85
+ - paywhirl.gemspec
86
+ homepage: https://github.com/paywhirl/ruby-pwclient
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.7.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Paywhirl API library for simplifying interaction with Paywhirl services.
110
+ test_files: []