cubits 0.1.0
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 +112 -0
- data/Rakefile +6 -0
- data/cubits.gemspec +28 -0
- data/lib/cubits/connection.rb +122 -0
- data/lib/cubits/errors.rb +27 -0
- data/lib/cubits/helpers.rb +35 -0
- data/lib/cubits/invoice.rb +6 -0
- data/lib/cubits/resource.rb +50 -0
- data/lib/cubits/version.rb +3 -0
- data/lib/cubits.rb +65 -0
- data/spec/lib/cubits/connection_spec.rb +12 -0
- data/spec/lib/cubits_spec.rb +41 -0
- data/spec/spec_helper.rb +15 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f407d28f07bf303f825ebc47aea0a17fe6e22b2c
|
4
|
+
data.tar.gz: 7e2a552de743466e54b1cda08d01a2ae8d4e15df
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4b801db8292d8a79a7c0ff07b785708d22b2aa49c88017bd0183797157e6f5020eb406554e4bc1791abe2fd22ddaaae67d4e4e7f3907777b1e3b81862dbd23e
|
7
|
+
data.tar.gz: 9a830abbb493de37e1de68e142a37e8353b478d2fc6e57738a08acd05b521193f170d77d1b486291b20742768bdd4ddc82e7aa918668ce0b6569eadf8fa3dca4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Cubits.com
|
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,112 @@
|
|
1
|
+
# Cubits API client
|
2
|
+
|
3
|
+
A Ruby 1.9+ client for [Cubits](https://cubits.com) Merchant API v1.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cubits'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cubits
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Configuration
|
24
|
+
|
25
|
+
First thing you have to do is to get your API token (key+secret) from Cubits *...Merchant integration tab?..*
|
26
|
+
|
27
|
+
Then, configure your Cubits client:
|
28
|
+
```ruby
|
29
|
+
require 'cubits'
|
30
|
+
|
31
|
+
Cubits.configure(key: '***', secret: '***')
|
32
|
+
```
|
33
|
+
|
34
|
+
Now you can test your API connection:
|
35
|
+
```ruby
|
36
|
+
require 'cubits'
|
37
|
+
|
38
|
+
Cubits.configure(key: '***', secret: '***')
|
39
|
+
|
40
|
+
Cubits.available? # => true
|
41
|
+
```
|
42
|
+
|
43
|
+
### Invoices
|
44
|
+
|
45
|
+
Using the `cubits` Ruby client you can create and retrieve invoices.
|
46
|
+
|
47
|
+
Invoices are represented by `Cubits::Invoice` class, which is a descendant of [Hashie::Mash](https://github.com/intridea/hashie#mash),
|
48
|
+
so it's a Hash with a method-like access to its elements:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
invoice.id # => "686e4238970a92f04f1f5a30035bf024"
|
52
|
+
invoice.status # => "pending"
|
53
|
+
invoice.invoice_amount # => "0.00446216"
|
54
|
+
invoice.invoice_currency # => "BTC"
|
55
|
+
invoice.address # => "2MwFC54RmUyHtyNcNuxtU5zW4hCGTvYuXti"
|
56
|
+
```
|
57
|
+
|
58
|
+
#### .create
|
59
|
+
|
60
|
+
Creates a new invoice.
|
61
|
+
|
62
|
+
For a list of accepted and returned parameters, see `POST /api/v1/invoices` page in the [Cubits Help Center](https://cubits.com/help) Developer's section.
|
63
|
+
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
invoice = Cubits::Invoice.create(price: '1.00', currency: 'EUR')
|
67
|
+
```
|
68
|
+
|
69
|
+
Here a call to `POST /api/v1/invoices` is executed and the response is wrapped in a `Cubits::Invoice` object.
|
70
|
+
|
71
|
+
|
72
|
+
#### .find(*id*)
|
73
|
+
|
74
|
+
Retrieves an existing invoice.
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
invoice = Cubits::Invoice.find("686e4238970a92f04f1f5a30035bf024")
|
78
|
+
```
|
79
|
+
|
80
|
+
Returns `Cubits::Invoice` object or `nil` if invoice was not found.
|
81
|
+
|
82
|
+
|
83
|
+
#### #reload
|
84
|
+
|
85
|
+
Reloads `Cubits::Invoice` object.
|
86
|
+
```ruby
|
87
|
+
invoice = Cubits::Invoice.find("686e4238970a92f04f1f5a30035bf024")
|
88
|
+
# do some stuff...
|
89
|
+
invoice.reload # gets the up-to-date invoice data from Cubits API
|
90
|
+
```
|
91
|
+
|
92
|
+
### Send money
|
93
|
+
|
94
|
+
`Cubits.send_money` helper method allows you to send Bitcoin from your Cubits Wallet to an external Bitcoin address.
|
95
|
+
|
96
|
+
#### Parameters
|
97
|
+
name | type | description
|
98
|
+
---------|---------|---------------------
|
99
|
+
amount | String | Amount in BTC to be sent, decimal as a String (e.g. "0.1234000")
|
100
|
+
address | String | Bitcoin address to send the amount to
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
Cubits.send_money amount: '1.5000000', address: '3BnYBqPnGtRz2cfcnhxFKy3JswU3biMk5q'
|
104
|
+
# => {"tx_ref_code"=>"64RHH"}
|
105
|
+
```
|
106
|
+
|
107
|
+
On success `.send_money` creates a transaction and returns its reference code.
|
108
|
+
|
109
|
+
----
|
110
|
+
|
111
|
+
|
112
|
+
|
data/Rakefile
ADDED
data/cubits.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cubits/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cubits'
|
8
|
+
spec.version = Cubits::VERSION
|
9
|
+
spec.authors = ['Alex Kukushkin']
|
10
|
+
spec.email = ['alex.kukushkin@cubits.com']
|
11
|
+
spec.summary = 'Ruby client for Cubits Merchant API'
|
12
|
+
spec.description = 'Ruby client for Cubits Merchant 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_dependency 'http', '~> 0.7'
|
22
|
+
spec.add_dependency 'hashie', '~> 3.3'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'json'
|
3
|
+
require 'http'
|
4
|
+
require 'openssl'
|
5
|
+
|
6
|
+
module Cubits
|
7
|
+
class Connection
|
8
|
+
CONTENT_TYPE = 'application/vnd.api+json'
|
9
|
+
|
10
|
+
#
|
11
|
+
# Creates a new Connection object
|
12
|
+
#
|
13
|
+
# @param params [Hash]
|
14
|
+
# @param params[:key] [String]
|
15
|
+
# @param params[:secret] [String]
|
16
|
+
#
|
17
|
+
def initialize(params)
|
18
|
+
fail ArgumentError, 'String is expected as :key' unless params[:key].is_a?(String)
|
19
|
+
fail ArgumentError, 'String is expected as :secret' unless params[:secret].is_a?(String)
|
20
|
+
@key = params[:key]
|
21
|
+
@secret = params[:secret]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Executes a GET request
|
25
|
+
#
|
26
|
+
def get(path, data = {})
|
27
|
+
fail ArgumentError, 'Hash is expected as request data' unless data.is_a?(Hash)
|
28
|
+
encoded_data = URI.encode_www_form(data)
|
29
|
+
request(:get, path, encoded_data)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Executes a POST request
|
33
|
+
#
|
34
|
+
def post(path, data = {})
|
35
|
+
fail ArgumentError, 'Hash is expected as request data' unless data.is_a?(Hash)
|
36
|
+
encoded_data = data.to_json
|
37
|
+
request(:post, path, encoded_data)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# Sends a request to the API
|
43
|
+
#
|
44
|
+
def request(method, path, encoded_data)
|
45
|
+
url = URI.join(Cubits.base_url, path)
|
46
|
+
url.query = encoded_data if method == :get && !encoded_data.empty?
|
47
|
+
params = {}
|
48
|
+
http = HTTP.with(cubits_headers(path, encoded_data))
|
49
|
+
http = http.with('Content-Type' => CONTENT_TYPE) unless method == :get
|
50
|
+
params[:body] = encoded_data unless method == :get
|
51
|
+
Cubits.logger.debug "> #{method.to_s.upcase}: #{url}"
|
52
|
+
response = http.send(method, url, params)
|
53
|
+
Cubits.logger.debug "< #{response.code} #{response.reason}"
|
54
|
+
begin
|
55
|
+
body = JSON.parse(response.body)
|
56
|
+
rescue JSON::ParserError => e
|
57
|
+
raise ConnectionError, "Failed to parse response: #{e}"
|
58
|
+
end
|
59
|
+
return body if (200...300).include?(response.status)
|
60
|
+
respond_with_error(response.code, body['message'])
|
61
|
+
end
|
62
|
+
|
63
|
+
# Map unsuccessful HTTP response to appropriate exception and raise it
|
64
|
+
#
|
65
|
+
def respond_with_error(status, message)
|
66
|
+
case status
|
67
|
+
when 400
|
68
|
+
fail BadRequest, message
|
69
|
+
when 403
|
70
|
+
fail Forbidden, message
|
71
|
+
when 404
|
72
|
+
fail NotFound, message
|
73
|
+
when 415
|
74
|
+
fail UnsupportedMediaType, message
|
75
|
+
when 500
|
76
|
+
fail InternalServerError, message
|
77
|
+
when 400...500
|
78
|
+
fail ClientError, message
|
79
|
+
when 500...600
|
80
|
+
fail ServerError, message
|
81
|
+
else
|
82
|
+
fail ConnectionError, message
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns timestamp based nonce
|
87
|
+
#
|
88
|
+
# @return [Integer]
|
89
|
+
#
|
90
|
+
def self.nonce
|
91
|
+
(Time.now.to_f * 1000).to_i
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns complete set of cubits headers
|
95
|
+
#
|
96
|
+
def cubits_headers(path, encoded_data)
|
97
|
+
nonce = self.class.nonce
|
98
|
+
signature = sign_request(path, nonce, encoded_data)
|
99
|
+
|
100
|
+
{
|
101
|
+
'CUBITS_KEY' => @key,
|
102
|
+
'CUBITS_NONCE' => nonce,
|
103
|
+
'CUBITS_SIGNATURE' => signature,
|
104
|
+
'Accept' => CONTENT_TYPE
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
# Calculates request signature
|
109
|
+
#
|
110
|
+
# @param path [String]
|
111
|
+
# @param nonce [Integer,String]
|
112
|
+
# @param request_data [String]
|
113
|
+
#
|
114
|
+
def sign_request(path, nonce, request_data)
|
115
|
+
msg = path + nonce.to_s + OpenSSL::Digest::SHA256.hexdigest(request_data)
|
116
|
+
signature = OpenSSL::HMAC.hexdigest('sha512', @secret, msg)
|
117
|
+
Cubits.logger.debug 'sign_request: ' \
|
118
|
+
"path=#{path} nonce=#{nonce} request_data=#{request_data} msg=#{msg} signature=#{signature}"
|
119
|
+
signature
|
120
|
+
end
|
121
|
+
end # class Connection
|
122
|
+
end # module Cubits
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Cubits
|
2
|
+
class ConnectionError < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
# HTTP 4xxx
|
6
|
+
class ClientError < ConnectionError
|
7
|
+
end
|
8
|
+
|
9
|
+
class BadRequest < ClientError
|
10
|
+
end
|
11
|
+
|
12
|
+
class Forbidden < ClientError
|
13
|
+
end
|
14
|
+
|
15
|
+
class NotFound < ClientError
|
16
|
+
end
|
17
|
+
|
18
|
+
class UnsupportedMediaType < ClientError
|
19
|
+
end
|
20
|
+
|
21
|
+
# HTTP 5xx
|
22
|
+
class ServerError < ConnectionError
|
23
|
+
end
|
24
|
+
|
25
|
+
class InternalServerError < ServerError
|
26
|
+
end
|
27
|
+
end # module Cubits
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Cubits
|
2
|
+
module Helpers
|
3
|
+
#
|
4
|
+
# Runs a few calls to Cubits API and returns true if the connection
|
5
|
+
# to the API is configured correctly.
|
6
|
+
#
|
7
|
+
def available?
|
8
|
+
Cubits.connection.get('/api/v1/test', foo: 'bar')
|
9
|
+
Cubits.connection.post('/api/v1/test', foo: 'bar')
|
10
|
+
true
|
11
|
+
rescue StandardError
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Executes "Send money" API call.
|
17
|
+
# Sends Bitcoins from Cubits Wallet to external Bitcoin address.
|
18
|
+
#
|
19
|
+
# @param params [Hash]
|
20
|
+
# @param params[:amount] [String] Amount to be sent, decimal as a String (e.g. "0.12340000")
|
21
|
+
# @param params[:address] [String] Bitcoin address the amount is to be sent to
|
22
|
+
#
|
23
|
+
def send_money(params)
|
24
|
+
fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)
|
25
|
+
fail ArgumentError, 'String is expected as :amount' unless params[:amount].is_a?(String)
|
26
|
+
fail ArgumentError, 'String is expected as :address' unless params[:address].is_a?(String)
|
27
|
+
fail ArgumentError, 'Invalid amount format' unless params[:amount] =~ /^\d+\.\d+$/
|
28
|
+
fail ArgumentError, 'Invalid address format' unless params[:address] =~ /^[A-Za-z0-9]+$/
|
29
|
+
Cubits.connection.post(
|
30
|
+
'/api/v1/send_money',
|
31
|
+
amount: params[:amount], address: params[:address]
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end # module Helpers
|
35
|
+
end # module Cubits
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
|
3
|
+
module Cubits
|
4
|
+
class Resource < Hashie::Mash
|
5
|
+
#
|
6
|
+
# Sets path for the resource
|
7
|
+
#
|
8
|
+
def self.path(p)
|
9
|
+
@path = p
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns API path to resource
|
13
|
+
#
|
14
|
+
def self.path_to(resource_or_id = nil)
|
15
|
+
fail ArgumentError, "Resource path is not set for #{self.class.name}" unless @path
|
16
|
+
if resource_or_id.is_a?(Resource)
|
17
|
+
"#{@path}/#{resource_or_id.id}"
|
18
|
+
elsif resource_or_id
|
19
|
+
"#{@path}/#{resource_or_id}"
|
20
|
+
else
|
21
|
+
@path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Loads resource
|
26
|
+
#
|
27
|
+
# @param id [String]
|
28
|
+
#
|
29
|
+
# @return nil if resource is not found
|
30
|
+
#
|
31
|
+
def self.find(id)
|
32
|
+
self.new Cubits.connection.get(path_to(id))
|
33
|
+
rescue NotFound
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
37
|
+
# Reloads resource
|
38
|
+
#
|
39
|
+
def reload
|
40
|
+
fail "Resource #{self.class.name} does not have an id" unless self.respond_to?(:id)
|
41
|
+
replace(self.class.find(id))
|
42
|
+
end
|
43
|
+
|
44
|
+
# Creates a new resource
|
45
|
+
#
|
46
|
+
def self.create(params = {})
|
47
|
+
self.new Cubits.connection.post(path_to, params)
|
48
|
+
end
|
49
|
+
end # class Resource
|
50
|
+
end # module Cubits
|
data/lib/cubits.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
require 'cubits/version'
|
4
|
+
require 'cubits/connection'
|
5
|
+
require 'cubits/errors'
|
6
|
+
require 'cubits/helpers'
|
7
|
+
require 'cubits/resource'
|
8
|
+
require 'cubits/invoice'
|
9
|
+
|
10
|
+
module Cubits
|
11
|
+
extend Cubits::Helpers
|
12
|
+
|
13
|
+
DEFAULT_BASE_URL = URI.parse('https://pay.cubits.com/')
|
14
|
+
|
15
|
+
#
|
16
|
+
# Configure Cubits connection
|
17
|
+
#
|
18
|
+
# @param params [Hash]
|
19
|
+
# @param params[:key] [String] API key obtained from Cubits
|
20
|
+
# @param params[:secret] [String] API secret obtained from Cubits
|
21
|
+
#
|
22
|
+
def self.configure(params = {})
|
23
|
+
@connection = Connection.new(params)
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Returns configured Connection object
|
28
|
+
#
|
29
|
+
def self.connection
|
30
|
+
@connection || fail('Cubits connection is not configured')
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns current Logger object
|
34
|
+
#
|
35
|
+
def self.logger
|
36
|
+
@logger ||= Logger.new(nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Sets new Logger object
|
40
|
+
#
|
41
|
+
def self.logger=(new_logger)
|
42
|
+
@logger = new_logger
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns current base API URL
|
46
|
+
#
|
47
|
+
def self.base_url
|
48
|
+
@base_url ||= DEFAULT_BASE_URL
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sets new base API URL
|
52
|
+
#
|
53
|
+
# @param new_base_url [URI]
|
54
|
+
#
|
55
|
+
def self.base_url=(new_base_url)
|
56
|
+
fail ArgumentError, 'URI is expected as new_base_url' unless new_base_url.is_a?(URI)
|
57
|
+
@base_url = new_base_url
|
58
|
+
end
|
59
|
+
# Resets all internal states
|
60
|
+
#
|
61
|
+
def self.reset
|
62
|
+
@connection = nil
|
63
|
+
@logger = nil
|
64
|
+
end
|
65
|
+
end # module Cubits
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cubits::Connection do
|
4
|
+
let(:key) { 'blablaKEY' }
|
5
|
+
let(:secret) { 'blablaSECRET' }
|
6
|
+
|
7
|
+
subject { described_class.new(key: key, secret: secret) }
|
8
|
+
|
9
|
+
it { is_expected.to respond_to(:get) }
|
10
|
+
it { is_expected.to respond_to(:post) }
|
11
|
+
|
12
|
+
end # describe Cubits::Connection
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cubits do
|
4
|
+
let(:key) { 'blablakey' }
|
5
|
+
let(:secret) { 'blablasecret' }
|
6
|
+
|
7
|
+
context '.configure' do
|
8
|
+
it 'fails if key is missing' do
|
9
|
+
expect { Cubits.configure(secret: secret) }.to raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'fails if secret is missing' do
|
13
|
+
expect { Cubits.configure(key: key) }.to raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'runs without errors if key and secret are present' do
|
17
|
+
expect { Cubits.configure(key: key, secret: secret) }.to_not raise_error
|
18
|
+
end
|
19
|
+
end # .configure
|
20
|
+
|
21
|
+
context '.connection' do
|
22
|
+
subject { Cubits.connection }
|
23
|
+
|
24
|
+
it 'fails when connection is not configured' do
|
25
|
+
expect { subject }.to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns Connection object when connection is configured' do
|
29
|
+
Cubits.configure(key: key, secret: secret)
|
30
|
+
expect { subject }.to_not raise_error
|
31
|
+
expect(subject).to be_a Cubits::Connection
|
32
|
+
end
|
33
|
+
end # .connection
|
34
|
+
|
35
|
+
context '.logger' do
|
36
|
+
subject { Cubits.logger }
|
37
|
+
|
38
|
+
it { is_expected.to be_a Logger }
|
39
|
+
end # .logger
|
40
|
+
|
41
|
+
end # describe Cubits
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cubits
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Kukushkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Ruby client for Cubits Merchant API
|
98
|
+
email:
|
99
|
+
- alex.kukushkin@cubits.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- cubits.gemspec
|
110
|
+
- lib/cubits.rb
|
111
|
+
- lib/cubits/connection.rb
|
112
|
+
- lib/cubits/errors.rb
|
113
|
+
- lib/cubits/helpers.rb
|
114
|
+
- lib/cubits/invoice.rb
|
115
|
+
- lib/cubits/resource.rb
|
116
|
+
- lib/cubits/version.rb
|
117
|
+
- spec/lib/cubits/connection_spec.rb
|
118
|
+
- spec/lib/cubits_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
homepage: ''
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.2.2
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Ruby client for Cubits Merchant API
|
144
|
+
test_files:
|
145
|
+
- spec/lib/cubits/connection_spec.rb
|
146
|
+
- spec/lib/cubits_spec.rb
|
147
|
+
- spec/spec_helper.rb
|