cubits 0.2.1 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGES.md +8 -0
- data/README.md +57 -2
- data/lib/cubits/channel.rb +6 -0
- data/lib/cubits/resource.rb +10 -0
- data/lib/cubits/version.rb +1 -1
- data/lib/cubits.rb +2 -1
- data/spec/lib/cubits/channel_spec.rb +13 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8949b7a2569642b35ee5fc65b2be3fdbec72e192
|
4
|
+
data.tar.gz: 111fa99d8f2ffcfb6b8c3f63626a07475e46cd7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b73fc2b6b9397db6af35561893e82fa3b36a61db81f97b5240554fa639bef7ecf0d80f9c653623090f00ec0adbcaa03330205e6f295bbfc57630672a21e595cc
|
7
|
+
data.tar.gz: 7a4bed20e2d5cd036aa654e154bbcbfccd1c579c99651ce4e58a0f625db478aaeb5e4c5c55305db00cdac6b3b9fc1e31ff54f22245cef8ccf82de0268686ef9a
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -88,6 +88,63 @@ invoice = Cubits::Invoice.find("686e4238970a92f04f1f5a30035bf024")
|
|
88
88
|
invoice.reload # gets the up-to-date invoice data from the Cubits API
|
89
89
|
```
|
90
90
|
|
91
|
+
## Channels
|
92
|
+
|
93
|
+
Using the `cubits` Ruby client you can create, update and retrieve channels.
|
94
|
+
|
95
|
+
Channels are represented by the `Cubits::Channel` class, which is a descendant of [Hashie::Mash](https://github.com/intridea/hashie#mash), so it's a Hash with a method-like access to its elements:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
channel.id # => "d17ad6c96f83162a2764ecd4739d7ab2"
|
99
|
+
channel.receiver_currency # => "EUR"
|
100
|
+
channel.address # => "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC"
|
101
|
+
```
|
102
|
+
|
103
|
+
#### .create
|
104
|
+
|
105
|
+
Creates a new channel.
|
106
|
+
|
107
|
+
For a list of accepted and returned parameters, see the `POST /api/v1/channels` page in the [Cubits Help Center](https://cubits.com/help) Developer's section.
|
108
|
+
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
channel = Cubits::Channel.create(receiver_currency: 'EUR')
|
112
|
+
```
|
113
|
+
|
114
|
+
Here a call to `POST /api/v1/channels` is executed and the response is wrapped in a `Cubits::Channel` object.
|
115
|
+
|
116
|
+
#### .find(*id*)
|
117
|
+
|
118
|
+
Retrieves an existing channel.
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
channel = Cubits::Channel.find("d17ad6c96f83162a2764ecd4739d7ab2")
|
122
|
+
```
|
123
|
+
|
124
|
+
Returns `Cubits::Channel` object or `nil` if the specified channel was not found.
|
125
|
+
|
126
|
+
#### #reload
|
127
|
+
|
128
|
+
Reloads `Cubits::Channel` object.
|
129
|
+
```ruby
|
130
|
+
channel = Cubits::Channel.find("d17ad6c96f83162a2764ecd4739d7ab2")
|
131
|
+
# do some stuff...
|
132
|
+
channel.reload # gets the up-to-date channel data from the Cubits API
|
133
|
+
```
|
134
|
+
|
135
|
+
#### #update
|
136
|
+
|
137
|
+
Updates attributes of the channel.
|
138
|
+
|
139
|
+
For a list of accepted parameters, see the `POST /api/v1/channels/{id}` page in the [Cubits Help Center](https://cubits.com/help) Developer's section.
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
channel = Cubits::Channel.find("d17ad6c96f83162a2764ecd4739d7ab2")
|
143
|
+
channel.reference # => nil
|
144
|
+
channel.update(reference: "CHAN_192357")
|
145
|
+
channel.reference # => "CHAN_192357"
|
146
|
+
```
|
147
|
+
|
91
148
|
## Accounts
|
92
149
|
|
93
150
|
Your Cubits accounts are represented by the `Cubits::Account` class, which is a descendant of [Hashie::Mash](https://github.com/intridea/hashie#mash), so it's a Hash with a method-like access to its elements:
|
@@ -201,5 +258,3 @@ On success `.send_money` creates a transaction and returns its reference code.
|
|
201
258
|
|
202
259
|
----
|
203
260
|
|
204
|
-
|
205
|
-
|
data/lib/cubits/resource.rb
CHANGED
@@ -74,6 +74,16 @@ module Cubits
|
|
74
74
|
replace(self.class.find(id))
|
75
75
|
end
|
76
76
|
|
77
|
+
# Updates the resource
|
78
|
+
#
|
79
|
+
def update(params = {})
|
80
|
+
unless self.class.exposed_method?(:update)
|
81
|
+
fail NoMethodError, "Resource #{self.class.name} does not expose #update"
|
82
|
+
end
|
83
|
+
fail "Resource #{self.class.name} does not have an id" unless self.respond_to?(:id)
|
84
|
+
replace(self.class.new Cubits.connection.post(self.class.path_to(id), params))
|
85
|
+
end
|
86
|
+
|
77
87
|
# Creates a new resource
|
78
88
|
#
|
79
89
|
def self.create(params = {})
|
data/lib/cubits/version.rb
CHANGED
data/lib/cubits.rb
CHANGED
@@ -8,11 +8,12 @@ require 'cubits/resource'
|
|
8
8
|
require 'cubits/invoice'
|
9
9
|
require 'cubits/account'
|
10
10
|
require 'cubits/quote'
|
11
|
+
require 'cubits/channel'
|
11
12
|
|
12
13
|
module Cubits
|
13
14
|
extend Cubits::Helpers
|
14
15
|
|
15
|
-
DEFAULT_BASE_URL = URI.parse('https://
|
16
|
+
DEFAULT_BASE_URL = URI.parse('https://api.cubits.com/')
|
16
17
|
|
17
18
|
#
|
18
19
|
# Configure Cubits connection
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cubits::Channel do
|
4
|
+
context 'class methods,' do
|
5
|
+
subject { described_class }
|
6
|
+
|
7
|
+
it { is_expected.to respond_to(:create) }
|
8
|
+
it { is_expected.to respond_to(:find) }
|
9
|
+
end # class methods
|
10
|
+
|
11
|
+
it { is_expected.to respond_to(:update) }
|
12
|
+
it { is_expected.to respond_to(:reload) }
|
13
|
+
end # describe Cubits::Channel
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cubits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kukushkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- cubits.gemspec
|
111
111
|
- lib/cubits.rb
|
112
112
|
- lib/cubits/account.rb
|
113
|
+
- lib/cubits/channel.rb
|
113
114
|
- lib/cubits/connection.rb
|
114
115
|
- lib/cubits/errors.rb
|
115
116
|
- lib/cubits/helpers.rb
|
@@ -118,6 +119,7 @@ files:
|
|
118
119
|
- lib/cubits/resource.rb
|
119
120
|
- lib/cubits/version.rb
|
120
121
|
- spec/lib/cubits/account_spec.rb
|
122
|
+
- spec/lib/cubits/channel_spec.rb
|
121
123
|
- spec/lib/cubits/connection_spec.rb
|
122
124
|
- spec/lib/cubits/helpers_spec.rb
|
123
125
|
- spec/lib/cubits/invoice_spec.rb
|
@@ -150,6 +152,7 @@ specification_version: 4
|
|
150
152
|
summary: Ruby client for Cubits Merchant API
|
151
153
|
test_files:
|
152
154
|
- spec/lib/cubits/account_spec.rb
|
155
|
+
- spec/lib/cubits/channel_spec.rb
|
153
156
|
- spec/lib/cubits/connection_spec.rb
|
154
157
|
- spec/lib/cubits/helpers_spec.rb
|
155
158
|
- spec/lib/cubits/invoice_spec.rb
|