coinpayments 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4ed64bfd5759998b686007427362f6d34b9d5b6
4
- data.tar.gz: 46c5d747bf79afadd4e68479a5a4da1e3cc10860
3
+ metadata.gz: dcc5cf6663ca02248fbceb9cdc104b41714f0bb6
4
+ data.tar.gz: 1c319813691953c48491e085c049c6950aa5f226
5
5
  SHA512:
6
- metadata.gz: 11d8d8a133bc9a01468c42200a5f209f61c7033f41af2fa58cc4e3a901bcfea9cdbbcff1b06f278ada9e04dc3b63a6ffffe2fced2bda9fc9826a8bbbee214905
7
- data.tar.gz: 2ca352514768b4e226d6e465d8271fe80407ac2fa9223a620ada18474439da0467324d38fe3e6186a3104e270ca670d65712c1b3125d6d1165a54e2eeed4a9da
6
+ metadata.gz: 518199c56965c6f9c02dd70d9bf837e7ba253e508234f73d9bc50c88ccb15e0aff05a678b957ed32301bdcd7ff6894cacb8c7c2e7a7b2b53d559a16af7c23f1a
7
+ data.tar.gz: 22ce68d4a9696797f7b8dd044e95e478dbe0a93b0938d32feafccbb0b754f0f29bfe0f99d30af9312fcc8f0ed36c133d3e0a553de2e5b3439461514b29294ed6
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.3.0
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # CoinPayments.net API ruby gem
1
+ # CoinPayments.net API Client
2
+ [![Gem Version](https://badge.fury.io/rb/coinpayments.svg)](https://badge.fury.io/rb/coinpayments) [![Build Status](https://travis-ci.org/Salet/coinpayments.svg?branch=master)](https://travis-ci.org/Salet/coinpayments) [![Code Climate](https://codeclimate.com/github/Salet/coinpayments/badges/gpa.svg)](https://codeclimate.com/github/Salet/coinpayments)
2
3
 
3
- This is a convenient wrapper around CoinPayments.net API (https://www.coinpayments.net/merchant-tools-api).
4
+ [CoinPayments](https://www.coinpayments.net) | [API Documentation](https://www.coinpayments.net/merchant-tools-api) | [Usage](#usage)
5
+
6
+ CoinPayments.net is a payment gateway that can allow you to accept Bitcoin, Litecoin, Ether and over [50 other popular cryptocurrencies](https://www.coinpayments.net/supported-coins) directly on your website.
7
+
8
+ This gem will let you to easily communicate with their API directly from your Ruby application. Want to accept Doge, Dash, START, or other less popular cryptocurrency? Search no more!
4
9
 
5
10
  ## Installation
6
11
 
@@ -18,29 +23,30 @@ Or install it yourself as:
18
23
 
19
24
  ## Configuration
20
25
 
21
- Before using this gem you have to set your Merchant ID and public/private API key pair, which can be accessed on your account at CoinPayments.net.
26
+ Before using this gem you will have to create an account on Coinpayments website. After that you can access your [Merchant ID](https://www.coinpayments.net/acct-settings) and generate [public/private API key pair](https://www.coinpayments.net/acct-api-keys) needed for this gem to work.
22
27
 
23
28
  If you are using Rails, simply generate a new config file, like so:
24
29
 
25
30
  $ rails generate coinpayments:install
26
31
 
27
- Configuration file can now be accessed at config/initializers/coinpayments.rb:
32
+ Configuration file can now be accessed at `config/initializers/coinpayments.rb`:
28
33
 
29
34
  ```
30
35
  Coinpayments.configure do |config|
31
- config.merchant_id = ''
32
- config.public_api_key = ''
36
+ config.merchant_id = ''
37
+ config.public_api_key = ''
33
38
  config.private_api_key = ''
34
39
  end
35
40
  ```
36
41
 
37
42
  ## Usage
43
+ `Coinpayments` is a singleton class with method names mimicking the command names of [CP API](https://www.coinpayments.net/merchant-tools-api).
44
+
45
+ Common required fields are automatically appended to each call. Other of the required parameters must be passed in as method attributes. You can add some optional parameters too.
46
+
47
+ For your convenience response fields can be accessed as method calls.
38
48
 
39
- - All method and field names are identical to official API documentation: https://www.coinpayments.net/merchant-tools-api.
40
- - Main required fields are appended to each call you make automatically.
41
- - Method required paramteres must be appended as method attributes.
42
- - Optional paramteres can be appended as an option hash
43
- - Call response is a Hashie::Mash instance, so you can access response hash parameters as method calls. For example, to quicly access BTC/USD exchange rate, use:
49
+ For example, to quickly access current BTC/USD exchange rate, use:
44
50
 
45
51
  `Coinpayments.rates.USD.rate_btc`
46
52
 
@@ -52,7 +58,7 @@ end
52
58
 
53
59
  - Check for cryptocurrencies you accept on your account:
54
60
 
55
- `Coinpayments.rates(accepted: 1).delete_if {|k, v| v["accepted"] == 0}.keys`
61
+ `Coinpayments.rates(accepted: 1).delete_if { |_k, v| v["accepted"] == 0 }.keys`
56
62
 
57
63
  - Create a transaction for $10 that must be payed using BTC, and display an address to the user:
58
64
 
data/Rakefile CHANGED
@@ -3,4 +3,6 @@ require "rake/testtask"
3
3
 
4
4
  Rake::TestTask.new do |t|
5
5
  t.test_files = FileList['test/*test.rb']
6
- end
6
+ end
7
+
8
+ task default: :test
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "coinpayments"
8
8
  spec.version = Coinpayments::VERSION
9
9
  spec.authors = ["Przemysław Janowski"]
10
- spec.email = ["przemyslaw.janowski@outlook.com"]
11
- spec.summary = "Convenient wrapper around CoinPayments.net API."
10
+ spec.email = ["p.janowski@outlook.com"]
11
+ spec.summary = "Ruby client for the CoinPayments.net API"
12
12
  spec.homepage = "https://github.com/Salet/coinpayments"
13
13
  spec.license = "MIT"
14
14
 
@@ -60,6 +60,11 @@ module Coinpayments
60
60
  api_call(args)
61
61
  end
62
62
 
63
+ def self.get_callback_address(currency, options = {})
64
+ args = { currency: currency }.merge!(options)
65
+ api_call(args)
66
+ end
67
+
63
68
  def self.get_withdrawal_info(id)
64
69
  args = { id: id }
65
70
  api_call(args)
@@ -10,4 +10,4 @@ module Coinpayments
10
10
  @private_api_key = ''
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Coinpayments
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  Coinpayments.configure do |config|
2
- config.merchant_id = ''
3
- config.public_api_key = ''
2
+ config.merchant_id = ''
3
+ config.public_api_key = ''
4
4
  config.private_api_key = ''
5
- end
5
+ end
@@ -49,4 +49,20 @@ class CoinpaymentsTest < Minitest::Test
49
49
  assert r.respond_to?(:status_text)
50
50
  end
51
51
  end
52
- end
52
+
53
+ def test_get_callback_address
54
+ VCR.use_cassette('get_callback_address') do
55
+ r = Coinpayments.get_callback_address('BTC')
56
+ assert r.kind_of?(Hash)
57
+ assert r.respond_to?(:address)
58
+ end
59
+ end
60
+
61
+ def test_get_withdrawal_info
62
+ VCR.use_cassette('get_withdrawal_info') do
63
+ r = Coinpayments.get_withdrawal_info('705565b8b8f068566fed1a71977ece30265c6e80cf7dfe854ab4a455701129bc')
64
+ assert r.kind_of?(Hash)
65
+ assert r.respond_to?(:status_text)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.coinpayments.net/api.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: version=1&key=ab62e52f47fb2e7032a3a678e8cfd66ed1e2beaa56edf0aa722d8fb15bd7afd0&cmd=get_callback_address&currency=BTC
9
+ headers:
10
+ Hmac:
11
+ - 389fd0db5e417387dd86023408066ab10392a55a3271a010cc23bbc2b5a1cdb8c8dc410d8304aab6b164df12776066cbfade0e0cd9a7a8220d7bd8115a0f73aa
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Date:
18
+ - Wed, 10 Aug 2016 20:03:31 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Content-Length:
22
+ - '72'
23
+ Connection:
24
+ - keep-alive
25
+ Set-Cookie:
26
+ - PHPSESSID=5c5pq7m5525sgdmdl6bb44dnn94jgn2ers0g4bevr3h7i5e4oh01; path=/; secure;
27
+ HttpOnly
28
+ - __cfduid=d73d7415d9e6270ef5be064e73c9891751470859410; expires=Thu, 10-Aug-17
29
+ 20:03:30 GMT; path=/; domain=.coinpayments.net; HttpOnly
30
+ X-Powered-By:
31
+ - PHP/5.4.45-0+deb7u4
32
+ X-Frame-Options:
33
+ - SAMEORIGIN
34
+ Strict-Transport-Security:
35
+ - max-age=2592000
36
+ Expires:
37
+ - Thu, 19 Nov 1981 08:52:00 GMT
38
+ Cache-Control:
39
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
40
+ Pragma:
41
+ - no-cache
42
+ Content-Disposition:
43
+ - attachment; filename=coinpayments_api.json
44
+ X-Content-Type-Options:
45
+ - nosniff
46
+ Server:
47
+ - cloudflare-nginx
48
+ Cf-Ray:
49
+ - 2d060d34718446c8-WAW
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"error":"ok","result":{"address":"18ahwWe9N1x7iHdnQYDDBT4E1buB7fcKwo"}}'
53
+ http_version:
54
+ recorded_at: Wed, 10 Aug 2016 20:03:31 GMT
55
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.coinpayments.net/api.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: version=1&key=ab62e52f47fb2e7032a3a678e8cfd66ed1e2beaa56edf0aa722d8fb15bd7afd0&cmd=get_withdrawal_info&id=705565b8b8f068566fed1a71977ece30265c6e80cf7dfe854ab4a455701129bc
9
+ headers:
10
+ Hmac:
11
+ - e2d725237384a3c99249c72b379fb72371b97d3c3116ef14652c3aa421ba0332c9c5d3eef42214cdd98d31e8598ef98ee5191c601aed21068fd80b3c3a131761
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Date:
18
+ - Wed, 10 Aug 2016 20:09:36 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Content-Length:
22
+ - '197'
23
+ Connection:
24
+ - keep-alive
25
+ Set-Cookie:
26
+ - PHPSESSID=lk1ev291daa5g7tns7kf3q4rq9ehngeg6emn0ji8d2phupmb3l41; path=/; secure;
27
+ HttpOnly
28
+ - __cfduid=d3baeb8f863a17477339aca69ccf1fc861470859775; expires=Thu, 10-Aug-17
29
+ 20:09:35 GMT; path=/; domain=.coinpayments.net; HttpOnly
30
+ X-Powered-By:
31
+ - PHP/5.4.45-0+deb7u4
32
+ X-Frame-Options:
33
+ - SAMEORIGIN
34
+ Strict-Transport-Security:
35
+ - max-age=2592000
36
+ Expires:
37
+ - Thu, 19 Nov 1981 08:52:00 GMT
38
+ Cache-Control:
39
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
40
+ Pragma:
41
+ - no-cache
42
+ Content-Disposition:
43
+ - attachment; filename=coinpayments_api.json
44
+ X-Content-Type-Options:
45
+ - nosniff
46
+ Server:
47
+ - cloudflare-nginx
48
+ Cf-Ray:
49
+ - 2d06161d6e362af1-WAW
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"error":"ok","result":{"time_created":1391924372,"status":2,"status_text":"Complete","coin":"BTC","amount":40000000,"amountf":"0.40000000","send_address":"1BitcoinAddress","send_txid":"hex_txid"}}'
53
+ http_version:
54
+ recorded_at: Wed, 10 Aug 2016 20:09:36 GMT
55
+ recorded_with: VCR 3.0.1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coinpayments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Przemysław Janowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-20 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,12 +124,13 @@ dependencies:
124
124
  version: '0'
125
125
  description:
126
126
  email:
127
- - przemyslaw.janowski@outlook.com
127
+ - p.janowski@outlook.com
128
128
  executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
+ - ".travis.yml"
133
134
  - Gemfile
134
135
  - LICENSE.txt
135
136
  - README.md
@@ -144,7 +145,9 @@ files:
144
145
  - test/fixtures/balances.yml
145
146
  - test/fixtures/create_transaction.yml
146
147
  - test/fixtures/create_withdrawal.yml
148
+ - test/fixtures/get_callback_address.yml
147
149
  - test/fixtures/get_tx_info.yml
150
+ - test/fixtures/get_withdrawal_info.yml
148
151
  - test/fixtures/rates.yml
149
152
  homepage: https://github.com/Salet/coinpayments
150
153
  licenses:
@@ -166,15 +169,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
169
  version: '0'
167
170
  requirements: []
168
171
  rubyforge_project:
169
- rubygems_version: 2.5.1
172
+ rubygems_version: 2.6.6
170
173
  signing_key:
171
174
  specification_version: 4
172
- summary: Convenient wrapper around CoinPayments.net API.
175
+ summary: Ruby client for the CoinPayments.net API
173
176
  test_files:
174
177
  - test/coinpayments_test.rb
175
178
  - test/fixtures/balances.yml
176
179
  - test/fixtures/create_transaction.yml
177
180
  - test/fixtures/create_withdrawal.yml
181
+ - test/fixtures/get_callback_address.yml
178
182
  - test/fixtures/get_tx_info.yml
183
+ - test/fixtures/get_withdrawal_info.yml
179
184
  - test/fixtures/rates.yml
180
- has_rdoc: