cuecloud 0.8.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc115167cb219e517186034afe635e122b47333e
4
+ data.tar.gz: c6446a9a64a1dd3dc4c2b9c4323be18c46ec9492
5
+ SHA512:
6
+ metadata.gz: 8a3be5bbe4ae2d03d956b4991ba7806f1731b17a5be6d9049a366afe730f257955e6eeab2688a142b18968b046363ee874a9489b07a59fca4f29626b8ad6237f
7
+ data.tar.gz: e0a24c27b607f90a64241ba05901932754930d05e6745c86c93f815461b306db9c42fd956ae68ce1379a3386499e11ea7b428c21a9e3958dd91a1b5ccebedfcb
data/.gitignore ADDED
@@ -0,0 +1,36 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+ /python
23
+ .idea
24
+
25
+ ## Environment normalisation:
26
+ /.bundle/
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+ ruby '2.1.2'
3
+ #ruby-gemset=cuecloud
4
+
5
+ gem 'rspec'
6
+ gem 'rspec-expectations'
7
+
8
+ group :test do
9
+ gem 'rake'
10
+ end
11
+
12
+
13
+ # Specify your gem's dependencies in cuecloud-gem.gemspec
14
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 ronniebermejo
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,41 @@
1
+ # Cuecloud
2
+
3
+ ## Description
4
+
5
+ Integration library for CueCloud
6
+
7
+ ## Requirements
8
+
9
+ ruby 2.1.2 or higher
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'cuecloud'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install cuecloud
24
+
25
+ ## Usage
26
+
27
+
28
+ ```ruby
29
+
30
+ require 'cuecloud'
31
+ include CueCloud
32
+
33
+ cuecloud = CueCloudApi.new('test_api_key', 'test_api_pass')
34
+ my_balance = cuecloud.get_balance['Data']['Balance']
35
+ cuecloud.withdraw_funds(my_balance - (my_balance * 0.1))
36
+
37
+ ```
38
+
39
+ ### More info:
40
+ **Check the specs and code for instructions.**
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cuecloud"
8
+ spec.version = Cuecloud::VERSION
9
+ spec.authors = ["ronniebermejo"]
10
+ spec.email = ["ronnie.bermejo.mx@gmail.com"]
11
+ spec.summary = %q{Integration library for CueCloud}
12
+ spec.description = %q{Integration library for CueCloud and Ruby}
13
+ spec.homepage = 'https://github.com/cuecloud/cuecloud-ruby'
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","lib/cuecloud","cuecloud","."]
20
+
21
+ spec.add_runtime_dependency "httparty", '~>0.13'
22
+ spec.add_runtime_dependency "json", '~>1.8'
23
+
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake", "~> 10.4"
27
+
28
+ spec.post_install_message = 'Thanks for installing cuecloud for ruby.'
29
+ end
@@ -0,0 +1,213 @@
1
+ class CueCloudApi
2
+
3
+ DEFAULT_BASE_URL = 'https://cuecloud.com/'
4
+ API_VERSION = 'api/v1.0'
5
+
6
+ attr_accessor :request
7
+
8
+ def initialize(api_key, api_pass, base_url=nil)
9
+ unless base_url
10
+ base_url = CueCloudApi::DEFAULT_BASE_URL + CueCloudApi::API_VERSION
11
+ end
12
+ @request = CueCloudRequest.new(api_key, api_pass, base_url)
13
+ end
14
+
15
+ # This is a test method to make sure that
16
+ # the user has valid API credentials.
17
+ def validate_user
18
+ build_request('validate/', 'GET')
19
+ end
20
+
21
+ # This will return common keywords for Cues.
22
+ # Useful for CueCreation.
23
+ def get_keywords
24
+ build_request('cues/keywords/', 'GET')
25
+ end
26
+
27
+ #This will return the user's current balance, in USD.
28
+ def get_balance
29
+ build_request('balance/', 'GET')
30
+ end
31
+
32
+ # Given a valid CC on file in the app,
33
+ # This will deposit that amount into the user's balance.
34
+ # Note, a credit card may only be added within the app. Not the API.
35
+ def make_deposit(amount_in_usd, cc_last_four)
36
+ data = {
37
+ 'AmountInUSD' => amount_in_usd.to_f,
38
+ 'CreditCardLastFourDigits' => cc_last_four
39
+ }
40
+ build_request('payments/deposit/', 'POST', data)
41
+ end
42
+
43
+ # Given a PayPal email, this will deposit the funds
44
+ # immediately into that user's PayPal account.
45
+ # If no amount is specified, it will try and
46
+ # deduct the entire user's balance.
47
+ def withdraw_funds(amount_in_usd=nil)
48
+ data = {'AmountInUSD' => amount_in_usd.to_f}
49
+ build_request('payments/withdraw/', 'POST', data)
50
+ end
51
+
52
+ # This will grant a bonus to the user who has completed
53
+ # a particular Cue for us.
54
+ #
55
+ # A reason for the bonus must be specified, though here
56
+ # we default to "Thanks for your hard work!" if none is provided.
57
+ #
58
+ # Note to self can be proviuded, which is a string that can only be viewed
59
+ # by the person who granted the bonus. An example might be:
60
+ # "Bonus paid here on 2014-01-01 to see if it motivates better work from this person."
61
+ def grant_bonus(cue_completion_id, amount, reason='Thanks for your hard work!', note_to_self=nil)
62
+ data = {
63
+ 'CueCompletionID' => cue_completion_id,
64
+ 'Amount' => amount,
65
+ 'Reason' => reason,
66
+ 'NoteToSelf' => note_to_self
67
+ }
68
+ build_request('payments/bonus/', 'POST', data)
69
+ end
70
+
71
+ #Payment type may be one of `Deposits`, `Withdrawals`, or `Bonuses`.
72
+ #50 results will show per page.
73
+ def get_payments(payment_type=nil, payment_id=nil, note_to_self=nil, page=nil)
74
+
75
+ data = {
76
+ 'PaymentType' => payment_type,
77
+ 'PaymentID' => payment_id,
78
+ 'NoteToSelf' => note_to_self,
79
+ 'Page' => page
80
+ }
81
+
82
+ url = encode_data_in_url('payments/', data)
83
+ unless data.empty?
84
+ build_request(url, 'GET', data)
85
+ else
86
+ build_request(url, 'GET')
87
+ end
88
+
89
+ end
90
+
91
+ #This will approve a CueCompletion that has been submitted to the user's Cue.
92
+ def approve_cue_completion(cue_completion_id)
93
+ data = {'CueCompletionID' => cue_completion_id}
94
+ build_request('completions/approve/', 'POST', data)
95
+ end
96
+
97
+ #This will decline a CueCompletion that has been submitted to the user's Cue.
98
+ def decline_cue_completion(cue_completion_id)
99
+ data = {'CueCompletionID' => cue_completion_id}
100
+ build_request('completions/decline/', 'POST', data)
101
+ end
102
+
103
+ #This will cancel a Cue that you have posted, refunding your balance.
104
+ def cancel_cue(cue_id)
105
+ data = {'CueID' => cue_id}
106
+ build_request('cues/cancel/', 'POST', data)
107
+ end
108
+
109
+ # This will return CueCompletions for a particular Cue.
110
+ # Status options for CueCompletions are `Pending`, `Accepted`, and `Declined`.
111
+ def get_cue_completions(cue_id, cue_completion_id=nil, status=nil, page=nil)
112
+
113
+ data = {
114
+ 'CueID' => cue_id,
115
+ 'CueCompletionID' => cue_completion_id,
116
+ 'Status' => status,
117
+ 'Page' => page
118
+ }
119
+
120
+ url = encode_data_in_url('completions/', data)
121
+ unless data.empty?
122
+ build_request(url, 'GET', data)
123
+ else
124
+ build_request(url, 'GET')
125
+ end
126
+
127
+ end
128
+
129
+ #The only required items are `title`, `amount`, and `num_opportunities` (which defaults to 1
130
+ #An `iframe_url` can be specified if you want a user to fill out a custom form on your site.
131
+ def create_cue(title, amount, num_opportunities: 1,
132
+ description: nil, is_anonymous: nil, push_notification_on_cue_completion: nil,
133
+ disallow_anonymous: nil, iframe_url: nil, url_notification_on_cue_completion: nil,
134
+ email_notification_on_cue_completion: nil, lifetime_in_minutes: nil,
135
+ time_limit_to_complete_cue_in_minutes: nil, auto_approve_cue_completion_in_minutes: nil,
136
+ note_to_self: nil, keywords: nil)
137
+
138
+ data = {
139
+ 'Title' => title,
140
+ 'Amount' => amount,
141
+ 'NumOpportunities' => num_opportunities,
142
+ 'Description' => description,
143
+ 'IsAnonymous' => is_anonymous,
144
+ 'PushNotificationOnCueCompletion' => push_notification_on_cue_completion,
145
+ 'DisallowAnonymousCueCompletions' => disallow_anonymous,
146
+ 'iFrameURL' => iframe_url,
147
+ 'URLNotificationOnCueCompletion' => url_notification_on_cue_completion,
148
+ 'EmailNotificationOnCueCompletion' => email_notification_on_cue_completion,
149
+ 'LifetimeInMinutes' => lifetime_in_minutes,
150
+ 'TimeLimitToCompleteCueInMinutes' => time_limit_to_complete_cue_in_minutes,
151
+ 'AutoApproveCueCompletionAfterThisManyMinutes' => auto_approve_cue_completion_in_minutes,
152
+ 'NoteToSelf' => note_to_self,
153
+ 'Keywords' => keywords,
154
+ }
155
+ build_request("cues/create", "POST", data)
156
+
157
+ end
158
+
159
+ # This will get all Cues the user has created.
160
+ # `has_pending_cue_completions` is a boolean.
161
+ # status` can be one of 'Active', 'Complete', 'Canceled', or 'Expired'
162
+ def get_cues(cue_id: nil, group_id: nil, note_to_self: nil, has_pending_cue_completions: nil, status: nil, page: nil)
163
+ data = {
164
+ 'CueID' => cue_id,
165
+ 'GroupID' => group_id,
166
+ 'NoteToSelf' => note_to_self,
167
+ 'HasPendingCueCompletions' => has_pending_cue_completions,
168
+ 'Status' => status,
169
+ 'Page' => page
170
+ }
171
+
172
+ url = encode_data_in_url('cues/', data)
173
+ build_request(url, "GET")
174
+ end
175
+
176
+ # This will try and check-in or check-out a Cue depending
177
+ # on whether the Cue is already checked out by that user.
178
+ def assign_cue(cue_id)
179
+ data = {'CueID' => cue_id}
180
+ build_request('cues/assign/', "POST", data)
181
+ end
182
+
183
+ # This will submit the CueCompletion data, though
184
+ # In production the method will block any requests without an HTTP_REFERER.
185
+ def submit_cue_completion(assignment_id, answer_text: nil, video_url: nil, video_thumbnail_url: nil, image_url: nil, is_anonymous: nil)
186
+
187
+ data = {
188
+ 'AssignmentID' => assignment_id,
189
+ 'AnswerText' => answer_text,
190
+ 'VideoURL' => video_url,
191
+ 'VideoThumbnailURL' => video_thumbnail_url,
192
+ 'ImageURL' => image_url,
193
+ 'IsAnonymous' => is_anonymous
194
+ }
195
+ build_request('cues/complete/', "POST", data)
196
+ end
197
+
198
+ private
199
+
200
+ def encode_data_in_url(resource, data)
201
+ data.select! { |_key, value| !value.nil? }
202
+ unless data.empty?
203
+ resource + '?' + URI::encode(data.map { |x| x.to_a.join("=") }.join("&"))
204
+ else
205
+ resource
206
+ end
207
+ end
208
+
209
+ def build_request(url, method, data=nil)
210
+ request.build_request(url, method, data)
211
+ end
212
+
213
+ end
@@ -0,0 +1,5 @@
1
+ class CueCloudException < StandardError
2
+ def initialize(*args)
3
+ super(args)
4
+ end
5
+ end
@@ -0,0 +1,80 @@
1
+ class CueCloudRequest
2
+
3
+ include HTTParty
4
+
5
+ #uncomment the following line to debug the entire http party and have fun !
6
+ #debug_output $stdout
7
+
8
+ attr_reader :auth_key, :api_key, :api_pass, :base_url, :body, :logger
9
+
10
+ # base_uri CueCloudApi::DEFAULT_BASE_URL + CueCloudApi::API_VERSION
11
+
12
+ def initialize(api_key, api_pass,base_url=nil)
13
+ @api_key = api_key.to_s
14
+ @api_pass = api_pass.to_s
15
+ @auth_key = {username: api_key, password: api_pass}
16
+ if base_url
17
+ @base_url = base_url
18
+ else
19
+ @base_url = CueCloudApi::DEFAULT_BASE_URL + CueCloudApi::API_VERSION
20
+ end
21
+ end
22
+
23
+ def build_request(resource, method, data=nil)
24
+
25
+ url = build_url(resource)
26
+ body = prepare_body(method, data)
27
+ nonce = generate_nonce
28
+
29
+ message = nonce + url + body
30
+
31
+ headers = {
32
+ 'Access-Key' => api_key,
33
+ 'Access-Signature' => signature(message),
34
+ 'Access-Nonce' => nonce,
35
+ 'Content-Type' => 'application/json',
36
+ }
37
+
38
+ request_call(method, url, auth_key, headers, data)
39
+
40
+ end
41
+
42
+ private
43
+
44
+ def build_url(resource)
45
+ base_url + "/" + resource
46
+ end
47
+
48
+ def prepare_body(method, data)
49
+ if data && method =~ /post/i
50
+ data.to_json
51
+ else
52
+ ""
53
+ end
54
+ end
55
+
56
+ def request_call(method, url, auth_key, headers, data)
57
+ case method
58
+ when /get/i
59
+ body = self.class.get(url, basic_auth: auth_key, headers: headers).response.body
60
+ return JSON.parse(body)
61
+ when /post/i
62
+ body = self.class.post(url, basic_auth: auth_key, headers: headers, body: data.to_json).response.body
63
+ return JSON.parse(body)
64
+ when /put/i
65
+ when /delete/i
66
+ else
67
+ raise CueCloudException.new("Invalid method:#{method}")
68
+ end
69
+ end
70
+
71
+ def signature(message)
72
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_pass, message)
73
+ end
74
+
75
+ def generate_nonce
76
+ (Time.now.to_f * 1e6).to_i.to_s
77
+ end
78
+
79
+ end
80
+
@@ -0,0 +1,2 @@
1
+ require "cuecloud/gem/version"
2
+
data/lib/cuecloud.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'version'
2
+
3
+ require 'httparty'
4
+ require 'openssl'
5
+ require 'Base64'
6
+ require 'logger'
7
+ require 'json'
8
+ require 'open-uri'
9
+
10
+ module CueCloud
11
+ require 'cuecloud_api'
12
+ require 'cuecloud_request'
13
+ require 'cuecloud_exception'
14
+ end
15
+
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Cuecloud
2
+ VERSION = "0.8.0"
3
+ end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ describe CueCloudApi do
4
+
5
+ let(:test_api_key) {'42cef2c79a984e34'}
6
+ let(:test_api_pass) {'2152b0f3cc1649fb'}
7
+
8
+ let(:test_cc_last_four) { '1111' }
9
+ let(:pay_amount) { '%.2f' % (10.24 + rand).to_f }
10
+ let(:num_opportunities) { 4 }
11
+ let(:cuecloud_fee) {0.10} #10%
12
+
13
+ subject(:cuecloud) { CueCloudApi.new(test_api_key, test_api_pass) }
14
+
15
+ describe '.validate_user' do
16
+ it 'validates the user account and status code 200 is returned' do
17
+ expect(cuecloud.validate_user["StatusCode"]).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '.get_keywords' do
22
+ it 'get the keywords' do
23
+ expect(cuecloud.get_keywords['Data']['Keywords']).to include('facebook')
24
+ end
25
+ end
26
+
27
+ describe '.make_deposit' do
28
+ it 'add funds to user account' do
29
+ previous_balance = cuecloud.get_balance['Data']['Balance']
30
+ cuecloud.make_deposit(pay_amount, test_cc_last_four)
31
+ new_balance = cuecloud.get_balance['Data']['Balance']
32
+ expect((new_balance - previous_balance).abs).to be_within(0.1).of(pay_amount.to_f)
33
+ end
34
+ end
35
+
36
+ describe '.withdraw_funds' do
37
+ it 'subtract funds from user account' do
38
+ previous_balance = cuecloud.get_balance['Data']['Balance']
39
+ cuecloud.withdraw_funds(pay_amount)
40
+ new_balance = cuecloud.get_balance['Data']['Balance']
41
+ expect((new_balance - previous_balance).abs).to be_within(0.1).of(pay_amount.to_f)
42
+ end
43
+ end
44
+
45
+ describe '.create_cue' do
46
+ it 'creates a cue' do
47
+ previous_num_cues = cuecloud.get_cues['Data']['NumTotalResults']
48
+ previous_balance = cuecloud.get_balance['Data']['Balance']
49
+ new_cue = cuecloud.create_cue("New Cue", pay_amount, num_opportunities: num_opportunities)
50
+ new_num_cues = cuecloud.get_cues['Data']['NumTotalResults']
51
+ new_balance = cuecloud.get_balance['Data']['Balance']
52
+ expect(new_num_cues).to be > previous_num_cues
53
+ balance_difference = (previous_balance - new_balance).abs
54
+ difference_should_be =(pay_amount.to_f * num_opportunities * (1 + cuecloud_fee)).to_f
55
+ expect(balance_difference).to be_within(difference_should_be).of(0.1)
56
+ end
57
+ end
58
+
59
+ describe '.submit_cue_completion' do
60
+ it 'submits a cue completion' do
61
+ last_cue_id = cuecloud.get_cues['Data']['Cues'][0]['ID']
62
+ previous_num_completions = cuecloud.get_cue_completions(last_cue_id)['Data']['NumTotalResults']
63
+ assignment_id = cuecloud.assign_cue(last_cue_id)['Data']['AssignmentID']
64
+ cuecloud.submit_cue_completion( assignment_id, answer_text: 'My Answer')['Data']['CueCompletionID']
65
+ new_num_completions = cuecloud.get_cue_completions(last_cue_id)['Data']['NumTotalResults']
66
+ expect(new_num_completions).to be > previous_num_completions
67
+
68
+ end
69
+ end
70
+
71
+ describe '.grant_bonus' do
72
+ it 'grant a bonus' do
73
+ previous_num_payments = cuecloud.get_payments['Data']['NumTotalResults']
74
+ last_cue_id = cuecloud.get_cues(has_pending_cue_completions: true)['Data']['Cues'][0]['ID']
75
+ last_cue_completion_id = cuecloud.get_cue_completions(last_cue_id)['Data']['CueCompletions'][0]['ID']
76
+ cuecloud.grant_bonus(cue_completion_id=last_cue_completion_id, amount=pay_amount, reason='Nice work')
77
+ new_num_payments = cuecloud.get_payments['Data']['NumTotalResults']
78
+ expect(new_num_payments).to be > previous_num_payments
79
+ end
80
+ end
81
+
82
+ describe '.get_balance' do
83
+ it "returns the user's current balance" do
84
+ expect(cuecloud.get_balance["Data"]["Balance"]).to be_a(Numeric)
85
+ end
86
+ end
87
+
88
+ describe '.get_cues' do
89
+ it "returns all thec clues the user has created" do
90
+ expect(cuecloud.get_cues["Data"]["NumTotalResults"]).to be_a(Numeric)
91
+ end
92
+ end
93
+
94
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ include
3
+
4
+ describe CueCloudRequest do
5
+
6
+ let(:test_api_key) {'42cef2c79a984e34'}
7
+ let(:test_api_pass) {'2152b0f3cc1649fb'}
8
+
9
+ subject(:request) { CueCloudRequest.new(test_api_key, test_api_pass) }
10
+
11
+ let(:request_with_invalid_credentials) { CueCloudRequest.new(test_api_key, "wrong_password") }
12
+ let(:url) { CueCloudApi::DEFAULT_BASE_URL }
13
+
14
+ describe '#build_request' do
15
+ context "correct credentials" do
16
+ it 'makes a success request' do
17
+ expect(request.build_request('payments/', 'get')["StatusCode"]).to eq(200)
18
+ end
19
+ end
20
+ context "invalid credentials" do
21
+ it 'fails to make a call' do
22
+ expect(request_with_invalid_credentials.build_request('payments/', 'get')["StatusCode"]).to eq(401)
23
+ end
24
+ end
25
+
26
+ it "generates exception when an invalid method is passed" do
27
+ expect { request.build_request('payments/', 'nonexisting') }.to raise_exception CueCloudException
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,14 @@
1
+ require 'rspec'
2
+
3
+ $: << '.'
4
+ $: << 'lib'
5
+
6
+ require 'cuecloud'
7
+ # require 'lib/cuecloud/request'
8
+ # require 'lib/cuecloud/cuecloud_exception'
9
+
10
+ RSpec.configure do |config|
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cuecloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
5
+ platform: ruby
6
+ authors:
7
+ - ronniebermejo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
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.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
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.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.4'
69
+ description: Integration library for CueCloud and Ruby
70
+ email:
71
+ - ronnie.bermejo.mx@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - cuecloud-gem.gemspec
83
+ - lib/cuecloud.rb
84
+ - lib/cuecloud/cuecloud_api.rb
85
+ - lib/cuecloud/cuecloud_exception.rb
86
+ - lib/cuecloud/cuecloud_request.rb
87
+ - lib/cuecloud/gem.rb
88
+ - lib/version.rb
89
+ - spec/cuecloud_api_spec.rb
90
+ - spec/request_spec.rb
91
+ - spec/spec_helper.rb
92
+ homepage: https://github.com/cuecloud/cuecloud-ruby
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message: Thanks for installing cuecloud for ruby.
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ - lib/cuecloud
101
+ - cuecloud
102
+ - "."
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.2.2
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Integration library for CueCloud
119
+ test_files:
120
+ - spec/cuecloud_api_spec.rb
121
+ - spec/request_spec.rb
122
+ - spec/spec_helper.rb