cubits 0.2.1 → 0.3.1

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: 3f20d1982b3ef43be0e3b9b8cbc9fea14c1cd44f
4
- data.tar.gz: 193e702ea136342137d5c73f204e0135399051cc
3
+ metadata.gz: 8949b7a2569642b35ee5fc65b2be3fdbec72e192
4
+ data.tar.gz: 111fa99d8f2ffcfb6b8c3f63626a07475e46cd7b
5
5
  SHA512:
6
- metadata.gz: 21fc0a0189fa63b53c738a41252700a3a0075e2097706099ff6056614be1be2564f038281cd8a4e164897544b21b64dc6e7d17c614e54d0c1d8f9a53c53aa0f2
7
- data.tar.gz: fce9506b0b8c7d36b367f44505031981679727b0a533f8cfd633d7eafcc6bc10b58392efcce75a9f786fd09684ca11e9188b14fb9a8d4b84d8e702aee26c8613
6
+ metadata.gz: b73fc2b6b9397db6af35561893e82fa3b36a61db81f97b5240554fa639bef7ecf0d80f9c653623090f00ec0adbcaa03330205e6f295bbfc57630672a21e595cc
7
+ data.tar.gz: 7a4bed20e2d5cd036aa654e154bbcbfccd1c579c99651ce4e58a0f625db478aaeb5e4c5c55305db00cdac6b3b9fc1e31ff54f22245cef8ccf82de0268686ef9a
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.3.1
2
+
3
+ Changed API base URL to: https://api.cubits.com/
4
+
5
+ # 0.3.0
6
+
7
+ Added Cubits::Channel implementation
8
+
1
9
  # 0.2.1
2
10
 
3
11
  Minor fixes to README.
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
-
@@ -0,0 +1,6 @@
1
+ module Cubits
2
+ class Channel < Resource
3
+ path '/api/v1/channels'
4
+ expose_methods :create, :find, :reload, :update
5
+ end # class Channel
6
+ end
@@ -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 = {})
@@ -1,3 +1,3 @@
1
1
  module Cubits
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.1'
3
3
  end
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://pay.cubits.com/')
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.2.1
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-02-06 00:00:00.000000000 Z
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