coinsimple 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/coinsimple.gemspec +27 -0
- data/lib/coinsimple.rb +8 -0
- data/lib/coinsimple/business.rb +32 -0
- data/lib/coinsimple/invoice.rb +88 -0
- data/lib/coinsimple/version.rb +3 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b6845261bc6d2291d52eec8a66f3f42cb7972ba
|
4
|
+
data.tar.gz: 1ca83cf860041326975e0c4f1f70adb98d46ce4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3eee85bc60036510371bb2349bcd0be6ae9527f1d7d2eb41e25c08f46ceae6a45a79ddc95fe8986eba4f5ba7c2f1919b7794bfb218ef01b30556a3b8d3390278
|
7
|
+
data.tar.gz: dae8f2e003a755a55e0dfc15ba1fc270b40fab9fbd0ebe3245b194b9cb1b0a382e9611c9f9e4ec86c75eaaae028b120ef50e45f4a4c93eb3afe496fb21b4987b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 nitzanbl
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Coinsimple
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'coinsimple'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install coinsimple
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/coinsimple/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/coinsimple.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coinsimple/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "coinsimple"
|
8
|
+
spec.version = Coinsimple::VERSION
|
9
|
+
spec.authors = ["nitzanbl"]
|
10
|
+
spec.email = ["nitzanblanko@gmail.com"]
|
11
|
+
spec.summary = "coinsimple ruby API"
|
12
|
+
spec.description = "coinsimple ruby API"
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_dependency "http", "~> 0.6.3"
|
24
|
+
spec.add_dependency "json", "~> 1.8.1"
|
25
|
+
spec.add_dependency "hashit" , "~> 0.0.4"
|
26
|
+
|
27
|
+
end
|
data/lib/coinsimple.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "hashit"
|
2
|
+
require "http"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Coinsimple
|
6
|
+
class Business
|
7
|
+
NEW_INVOICE_URL = "https://app.coinsimple.com/api/v1/invoice"
|
8
|
+
|
9
|
+
def initialize business_id , api_key
|
10
|
+
@api_key=api_key
|
11
|
+
@business_id=business_id
|
12
|
+
end
|
13
|
+
|
14
|
+
def send_invoice invoice
|
15
|
+
options=invoice.data
|
16
|
+
options[:business_id]=@business_id
|
17
|
+
timestamp=Time.now.to_i
|
18
|
+
hash=Hashit.sha256(timestamp,@api_key)[3..-1]
|
19
|
+
options[:timestamp]=timestamp
|
20
|
+
options[:hash]=hash
|
21
|
+
|
22
|
+
res = HTTP.post NEW_INVOICE_URL, json: options
|
23
|
+
if res.status >= 400
|
24
|
+
{"status" => "error" , "error" => "error creating invoice"}
|
25
|
+
else
|
26
|
+
JSON.parse res.to_s
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Coinsimple
|
2
|
+
class Invoice
|
3
|
+
|
4
|
+
def initialize opts = {}
|
5
|
+
@options = opts
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_name recipient
|
9
|
+
@options[:name] = recipient
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_email email
|
14
|
+
@options[:email] = email
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_processor processor
|
19
|
+
@options[:processor] = processor
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_rate rate
|
24
|
+
@options[:rate] = rate
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_currency currency
|
29
|
+
@options[:currency] = currency
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_notes notes
|
34
|
+
@options[:notes] = notes
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_precent precent
|
39
|
+
@options[:precent] = precent
|
40
|
+
self
|
41
|
+
end
|
42
|
+
alias_method :set_discount , :set_precent
|
43
|
+
|
44
|
+
def set_custom custom
|
45
|
+
@options[:custom] = custom
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_callback_url callback_url
|
50
|
+
@options[:callback_url] = callback_url
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_redirect_url redirect_url
|
55
|
+
@options[:redirect_url] = redirect_url
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_recurring_times recurring_times
|
60
|
+
@options[:recurring_times] = recurring_times
|
61
|
+
self
|
62
|
+
end
|
63
|
+
alias_method :set_stop_after , :set_recurring_times
|
64
|
+
|
65
|
+
def recur_by_days num_days
|
66
|
+
@options[:invoice_type] = 'days'
|
67
|
+
@options[:interval] = num_days
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
def recur_by_date day_of_month
|
72
|
+
@options[:invoice_type] = 'date'
|
73
|
+
@options[:interval] = day_of_month
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_item item
|
78
|
+
@options[:items] = [] unless @options.has_key?(:items)
|
79
|
+
@options[:items] << item
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
def data
|
84
|
+
@options
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coinsimple
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nitzanbl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-24 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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: http
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.6.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.6.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: hashit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.4
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.4
|
83
|
+
description: coinsimple ruby API
|
84
|
+
email:
|
85
|
+
- nitzanblanko@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- coinsimple.gemspec
|
96
|
+
- lib/coinsimple.rb
|
97
|
+
- lib/coinsimple/business.rb
|
98
|
+
- lib/coinsimple/invoice.rb
|
99
|
+
- lib/coinsimple/version.rb
|
100
|
+
homepage: ''
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.2.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: coinsimple ruby API
|
124
|
+
test_files: []
|