coinjar 1.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/coinjar.gemspec +26 -0
- data/lib/coinjar/address.rb +21 -0
- data/lib/coinjar/client.rb +43 -0
- data/lib/coinjar/configuration.rb +27 -0
- data/lib/coinjar/payment.rb +45 -0
- data/lib/coinjar/transaction.rb +33 -0
- data/lib/coinjar/version.rb +3 -0
- data/lib/coinjar.rb +22 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e64f5f62668108d8f80d7676718cae632b9ae6c1
|
4
|
+
data.tar.gz: 96572402ab8699550cf57030cc3a330be47589d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e335e2131d37e47721c8a9c084796cf98662413cba2dadad47fd32f6d895d3303e709fc8fd94edaab1bb335191b321fb427ae066bc0785af42b99f777a92f55
|
7
|
+
data.tar.gz: 5608839d49b99b530edebd9442af5840b59730fee4c454d17a60ce3b252a193e0e2f3a46b19cd3a356c831fb8286935cfac6d1a0df5242e6f6e2702b962cf582
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Zhou Tong
|
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,29 @@
|
|
1
|
+
# CoinJar
|
2
|
+
|
3
|
+
The official CoinJar Ruby gem is the easiest way to interact with CoinJar API in your Ruby applications.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'coinjar'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install coinjar
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/coinjar.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coinjar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "coinjar"
|
8
|
+
spec.version = CoinJar::VERSION
|
9
|
+
spec.authors = ["CoinJar Pty Ltd", "Ryan Zhou", "Jerrold Poh"]
|
10
|
+
spec.email = ["info@coinjar.io"]
|
11
|
+
spec.description = ["Official Ruby gem for CoinJar."]
|
12
|
+
spec.summary = ["CoinJar is an easy-to-use Bitcoin payment platform."]
|
13
|
+
spec.homepage = "https://coinjar.io"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_runtime_dependency "rest-client"
|
24
|
+
spec.add_runtime_dependency "multi_json"
|
25
|
+
spec.add_runtime_dependency "activesupport"
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CoinJar
|
2
|
+
class Address
|
3
|
+
|
4
|
+
attr_accessor :address, :label
|
5
|
+
|
6
|
+
def initialize(args)
|
7
|
+
args.each do |k,v|
|
8
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.generate(label = nil)
|
13
|
+
self.new CoinJar.client.post("bitcoin_addresses", "label=#{label}")[:bitcoin_address]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.list(offset = 0, limit = 100)
|
17
|
+
CoinJar.client.get("bitcoin_addresses", { offset: offset, limit: limit }).map { |p| self.new p[:bitcoin_address] }
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module CoinJar
|
2
|
+
class Client
|
3
|
+
|
4
|
+
attr_accessor *Configuration::VALID_CONFIG_KEYS, :root_resource
|
5
|
+
|
6
|
+
def initialize(options={})
|
7
|
+
merged_options = CoinJar.config_options.merge(options)
|
8
|
+
Configuration::VALID_CONFIG_KEYS.each do |key|
|
9
|
+
send("#{key}=", merged_options[key])
|
10
|
+
end
|
11
|
+
@root_resource = RestClient::Resource.new(endpoint, :user => api_key)
|
12
|
+
end
|
13
|
+
|
14
|
+
def post(path, payload)
|
15
|
+
parse url(path).post(payload)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(path, params = nil)
|
19
|
+
parse url(path).get(:params => params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def put(path, payload)
|
23
|
+
parse url(path).put(payload)
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(path)
|
27
|
+
parse url(path).delete
|
28
|
+
end
|
29
|
+
|
30
|
+
def patch(path, payload)
|
31
|
+
parse url(path).patch(payload)
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse(response)
|
35
|
+
MultiJson.load(response, :symbolize_keys => true)
|
36
|
+
end
|
37
|
+
|
38
|
+
def url(path)
|
39
|
+
root_resource["#{path}.#{format}"]
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CoinJar
|
2
|
+
module Configuration
|
3
|
+
VALID_CONFIG_KEYS = [:api_key, :endpoint, :format]
|
4
|
+
|
5
|
+
DEFAULT_ENDPOINT = 'https://api.coinjar.io/v1'
|
6
|
+
DEFAULT_API_KEY = nil
|
7
|
+
DEFAULT_FORMAT = :json
|
8
|
+
|
9
|
+
attr_accessor *VALID_CONFIG_KEYS
|
10
|
+
|
11
|
+
# Make sure we have the default values set when we get 'extended'
|
12
|
+
def self.extended(base)
|
13
|
+
base.reset
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset
|
17
|
+
self.endpoint = DEFAULT_ENDPOINT
|
18
|
+
self.api_key = DEFAULT_API_KEY
|
19
|
+
self.format = DEFAULT_FORMAT
|
20
|
+
end
|
21
|
+
|
22
|
+
def config_options
|
23
|
+
Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module CoinJar
|
2
|
+
class Payment
|
3
|
+
|
4
|
+
attr_accessor :uuid, :payee, :payee_name, :amount, :status, :related_transaction_uuid, :created_at, :updated_at
|
5
|
+
|
6
|
+
def initialize(args)
|
7
|
+
reset(args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
response = CoinJar.client.post("payments", {:payment => self.instance_values})
|
12
|
+
self.reset(response[:payment])
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def confirm!
|
17
|
+
response = CoinJar.client.post("payments/#{uuid}/confirm", nil)
|
18
|
+
self.reset(response[:payment])
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def fetch
|
23
|
+
CoinJar.client.get("payments/" + uuid)[:payment]
|
24
|
+
self.reset(response[:payment])
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find(uuid)
|
29
|
+
payment = self.new(uuid: uuid)
|
30
|
+
payment.fetch
|
31
|
+
payment
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.list(offset = 0, limit = 100)
|
35
|
+
CoinJar.client.get("payments", { offset: offset, limit: limit })[:payments].map { |p| self.new p }
|
36
|
+
end
|
37
|
+
|
38
|
+
def reset(args)
|
39
|
+
args.each do |k,v|
|
40
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module CoinJar
|
2
|
+
class Transaction
|
3
|
+
|
4
|
+
attr_accessor :uuid, :counterparty_name, :counterparty_type, :amount, :status, :confirmations, :bitcoin_txid, :related_payment_uuid, :created_at, :updated_at
|
5
|
+
|
6
|
+
def initialize(args)
|
7
|
+
reset(args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def fetch
|
11
|
+
CoinJar.client.get("transactions/" + uuid)[:transaction]
|
12
|
+
self.reset(response[:transaction])
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.find(uuid)
|
17
|
+
transaction = self.new(uuid: uuid)
|
18
|
+
transaction.fetch
|
19
|
+
transaction
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.list(offset = 0, limit = 100)
|
23
|
+
CoinJar.client.get("transactions", { offset: offset, limit: limit })[:transactions].map { |t| self.new t }
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset(args)
|
27
|
+
args.each do |k,v|
|
28
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/lib/coinjar.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'active_support/core_ext/object'
|
2
|
+
require 'multi_json'
|
3
|
+
require 'rest_client'
|
4
|
+
|
5
|
+
require 'coinjar/version'
|
6
|
+
require 'coinjar/configuration'
|
7
|
+
require 'coinjar/client'
|
8
|
+
require 'coinjar/address'
|
9
|
+
require 'coinjar/payment'
|
10
|
+
require 'coinjar/transaction'
|
11
|
+
|
12
|
+
module CoinJar
|
13
|
+
extend Configuration
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def client
|
17
|
+
@client = CoinJar::Client.new unless defined?(@client) && @client.hash == config_options.hash
|
18
|
+
@client
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coinjar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- CoinJar Pty Ltd
|
8
|
+
- Ryan Zhou
|
9
|
+
- Jerrold Poh
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.3'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rest-client
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: multi_json
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: activesupport
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
description: '["Official Ruby gem for CoinJar."]'
|
86
|
+
email:
|
87
|
+
- info@coinjar.io
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- coinjar.gemspec
|
98
|
+
- lib/coinjar.rb
|
99
|
+
- lib/coinjar/address.rb
|
100
|
+
- lib/coinjar/client.rb
|
101
|
+
- lib/coinjar/configuration.rb
|
102
|
+
- lib/coinjar/payment.rb
|
103
|
+
- lib/coinjar/transaction.rb
|
104
|
+
- lib/coinjar/version.rb
|
105
|
+
homepage: https://coinjar.io
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>'
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.3.1
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.0.3
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: '["CoinJar is an easy-to-use Bitcoin payment platform."]'
|
129
|
+
test_files: []
|