spartacus 0.1.9 → 0.2.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 +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +11 -0
- data/LICENSE +22 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/lib/client/alumni_stories.rb +29 -0
- data/lib/client/base_client.rb +41 -0
- data/lib/client/checkpoints.rb +62 -0
- data/lib/client/class_factory.rb +31 -0
- data/lib/client/roadmap_sections.rb +30 -0
- data/lib/client/users.rb +220 -0
- data/spartacus.gemspec +21 -0
- data/spec/.keep +0 -0
- metadata +58 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 463d2d3196f7020795237b2ce625c2f91ff15896
|
4
|
+
data.tar.gz: 5073015371d6d0f9040540e4f79feed3de940292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7390f465b1c6b5cb81761c96c90cfb0754fe39c16fb91fbb4f7316512e0a0da715f6854c4e12141dd5f45b57309e883c789dca6938a1f0ecbe19caa78a99b26b
|
7
|
+
data.tar.gz: efc045df13159164354be16a6b08c3708f5150134a32834013645bcd6705aaceb59045b269adc33f2ac4e40fba6733d053e98a345b39e6b27bbfd5e3a1765367
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 bmneely
|
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,45 @@
|
|
1
|
+
#Spartacus
|
2
|
+
|
3
|
+
Ruby toolkit for the Bloc API.
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
##Quick start
|
8
|
+
|
9
|
+
Install via Rubygems
|
10
|
+
|
11
|
+
```bash
|
12
|
+
gem install spartacus
|
13
|
+
```
|
14
|
+
|
15
|
+
... or add to your Gemfile
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem "spartacus", "~> 0.1.6"
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Create a new `Spartacus` client using your Bloc username and password:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
sc = Spartacus.new("ben@bloc.io", "gooderpassword")
|
27
|
+
```
|
28
|
+
|
29
|
+
Then use the client to make requests:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
sc.update_checkpoint(129, {name: "New Checkpint Name"})
|
33
|
+
```
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create new Pull Request
|
42
|
+
|
43
|
+
## Acknowledgements
|
44
|
+
|
45
|
+
This gem is inspired by [octokit](https://github.com/octokit)
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'base_client'
|
2
|
+
|
3
|
+
module AlumniStories
|
4
|
+
include BaseClient
|
5
|
+
|
6
|
+
# Create a checkpoint
|
7
|
+
#
|
8
|
+
# @param id [Integer] An alumni story id.
|
9
|
+
# @param direction [String] The direction to move to the alumni story.
|
10
|
+
# @return [AlumniStory] The updated alumni story
|
11
|
+
# @example Update an alumni story sort order
|
12
|
+
# Spartacus#update_alum_story_sort_order(1, {name: 'Real Cool Checkpoint'})
|
13
|
+
def update_alum_story_sort_order(id, direction='down')
|
14
|
+
accepted_params = ['up', 'down', :up, :down]
|
15
|
+
if accepted_params.include?(direction)
|
16
|
+
|
17
|
+
url = "#{@api_base_path}/alum_stories/#{id}/update_sort_order"
|
18
|
+
|
19
|
+
handle_timeouts do
|
20
|
+
response = self.class.post(url,
|
21
|
+
headers: auth_header,
|
22
|
+
query: { direction: direction })
|
23
|
+
convert_response(response, "alumni_story")
|
24
|
+
end
|
25
|
+
else
|
26
|
+
raise InvalidDirectionError
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'class_factory'
|
2
|
+
|
3
|
+
module BaseClient
|
4
|
+
# Handle API timouts
|
5
|
+
def handle_timeouts
|
6
|
+
begin
|
7
|
+
yield
|
8
|
+
rescue Net::OpenTimeout, Net::ReadTimeout
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# This needs a better name
|
14
|
+
def convert_response(response, name)
|
15
|
+
if success?(response.code)
|
16
|
+
ClassFactory.build_response_object(response.body, name)
|
17
|
+
else
|
18
|
+
return response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def success?(code)
|
23
|
+
code.between?(200, 299)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Set the API Authorization Header
|
27
|
+
#
|
28
|
+
# @return [Hash] The authorization header
|
29
|
+
def auth_header
|
30
|
+
{ "authorization" => @auth_token }
|
31
|
+
end
|
32
|
+
|
33
|
+
def convert_keys(options)
|
34
|
+
options.keys.each {|k| options[k.to_s] = options.delete(k) if k.kind_of?(Symbol)}
|
35
|
+
options
|
36
|
+
end
|
37
|
+
|
38
|
+
def whitelist_params(options, whitelist)
|
39
|
+
options.select {|k, v| whitelist.include?(k)}
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative 'base_client'
|
2
|
+
|
3
|
+
module Checkpoints
|
4
|
+
include BaseClient
|
5
|
+
# Get a checkpoint
|
6
|
+
#
|
7
|
+
# @param id [Integer] A roadmap section id.
|
8
|
+
# @return [Checkpoint] The checkpoint.
|
9
|
+
# @example Get a checkpoint
|
10
|
+
# Spartacus#get_checkpoint(1, {name: 'Real Cool Checkpoint'})
|
11
|
+
def get_checkpoint(id)
|
12
|
+
url = "#{@api_base_path}/checkpoints/#{id}"
|
13
|
+
|
14
|
+
handle_timeouts do
|
15
|
+
response = self.class.get(url, headers: auth_header)
|
16
|
+
convert_response(response, "checkpoint")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Update a checkpoint
|
21
|
+
#
|
22
|
+
# @param id [Integer] A checkpoint id.
|
23
|
+
# @param options [Hash] A customizable set of options.
|
24
|
+
# @option options [String] :name Checkpoint name.
|
25
|
+
# @option options [String] :summary Checkpoint summary.
|
26
|
+
# @option options [String] :body Checkpoint body.
|
27
|
+
# @option options [String] :assignment Checkpoint assignment.
|
28
|
+
# @option options [String] :assignment Checkpoint body and assignment.
|
29
|
+
# @option options [Integer] :points Checkpoint point.
|
30
|
+
# @option options [String] :body_and_assignment Checkpoint body and Assignment
|
31
|
+
# @return [Checkpoint] The updated checkpoint
|
32
|
+
# @example Update a checkpoint
|
33
|
+
# Spartacus#update_checkpoint(129, {name: 'Real Cool Checkpoint'})
|
34
|
+
def update_checkpoint(id, options={})
|
35
|
+
whitelist = ['name', 'summary', 'body', 'assignment','body_and_assignment', 'points']
|
36
|
+
|
37
|
+
options = convert_keys(options)
|
38
|
+
checkpoint_params = whitelist_params(options, whitelist)
|
39
|
+
url = "#{@api_base_path}/checkpoints/#{id}"
|
40
|
+
|
41
|
+
handle_timeouts do
|
42
|
+
response = self.class.put(url, headers: auth_header,
|
43
|
+
query: { checkpoint: checkpoint_params })
|
44
|
+
convert_response(response, "checkpoint")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Delete a checkpoint
|
49
|
+
#
|
50
|
+
# @param id [Integer] A checkpoint id.
|
51
|
+
# @return [Checkpoint] The deleted checkpoint.
|
52
|
+
# @example Delete a checkpoint
|
53
|
+
# Spartacus#delete_checkpoint(1, {name: 'Real Cool Checkpoint'})
|
54
|
+
def delete_checkpoint(id)
|
55
|
+
url = "#{@api_base_path}/checkpoints/#{id}"
|
56
|
+
|
57
|
+
handle_timeouts do
|
58
|
+
response = self.class.delete(url, headers: auth_header)
|
59
|
+
convert_response(response, "checkpoint")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
|
4
|
+
module ClassFactory
|
5
|
+
def ClassFactory.build_response_object(json_string, name)
|
6
|
+
response_hash = JSON.parse(json_string)
|
7
|
+
if Object.const_defined?(name.camelize)
|
8
|
+
name.camelize.constantize.new(response_hash)
|
9
|
+
else
|
10
|
+
generic_class = ClassFactory::GenericClass.new
|
11
|
+
generic_class.create_class name
|
12
|
+
name.camelize.constantize.new(response_hash)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class GenericClass
|
17
|
+
def create_class name
|
18
|
+
Object.const_set(name.classify,
|
19
|
+
Class.new do
|
20
|
+
def initialize(hash)
|
21
|
+
hash.each do |k,v|
|
22
|
+
self.instance_variable_set("@#{k}", v)
|
23
|
+
self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")})
|
24
|
+
self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'base_client'
|
2
|
+
|
3
|
+
module RoadmapSections
|
4
|
+
include BaseClient
|
5
|
+
# Create a checkpoint
|
6
|
+
#
|
7
|
+
# @param id [Integer] A roadmap section id.
|
8
|
+
# @param options [Hash] A customizable set of options.
|
9
|
+
# @option options [String] :name Checkpoint name.
|
10
|
+
# @option options [String] :summary Checkpoint summary.
|
11
|
+
# @option options [String] :body Checkpoint body.
|
12
|
+
# @option options [String] :assignment Checkpoint assignment.
|
13
|
+
# @option options [Integer] :points Checkpoint point.
|
14
|
+
# @option options [String] :body_and_assignment Checkpoint body and Assignment
|
15
|
+
# @return [Checkpoint] The created checkpoint
|
16
|
+
# @example Create a checkpoint
|
17
|
+
# Spartacus#create_checkpoint(1, {name: 'Real Cool Checkpoint'})
|
18
|
+
def create_checkpoint(id, options={})
|
19
|
+
accepted_params = ['name', 'summary', 'body', 'assignment', 'points', 'body_and_assignment']
|
20
|
+
checkpoint_params = options.select {|k, v| accepted_params.include?(k) }
|
21
|
+
url = "#{@api_base_path}/roadmap_sections/#{id}/create_checkpoint"
|
22
|
+
|
23
|
+
handle_timeouts do
|
24
|
+
response = self.class.post(url,
|
25
|
+
headers: auth_header,
|
26
|
+
query: { checkpoint: checkpoint_params })
|
27
|
+
convert_response(response, "checkpoint")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/client/users.rb
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
module Users
|
2
|
+
|
3
|
+
# Get all users
|
4
|
+
#
|
5
|
+
# @return [HTTParty::Response] All users.
|
6
|
+
# @example Get all users
|
7
|
+
# Spartacus#get_users
|
8
|
+
def get_users
|
9
|
+
url = "#{@api_base_path}/users"
|
10
|
+
handle_timeouts do
|
11
|
+
self.class.get(url, headers: auth_header)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get your own user
|
16
|
+
#
|
17
|
+
# @return [User] You.
|
18
|
+
# @example Get yourself
|
19
|
+
# Spartacus#get_me
|
20
|
+
def get_me
|
21
|
+
url = "#{@api_base_path}/users/me"
|
22
|
+
handle_timeouts do
|
23
|
+
response = self.class.get(url, headers: auth_header)
|
24
|
+
convert_response(response, "user")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get all user
|
29
|
+
#
|
30
|
+
# @param id [Integer] A user id.
|
31
|
+
# @return [User] A user.
|
32
|
+
# @example Get a user
|
33
|
+
# Spartacus#get_user
|
34
|
+
def get_user(id)
|
35
|
+
url = "#{@api_base_path}/users/#{id}"
|
36
|
+
handle_timeouts do
|
37
|
+
response = self.class.get(url, headers: auth_header)
|
38
|
+
convert_response(response, "user")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get available mentors for a user
|
43
|
+
#
|
44
|
+
# @param id [Integer] A user id.
|
45
|
+
# @return [User] Available mentors.
|
46
|
+
# @example Get avaiable mentors
|
47
|
+
# Spartacus#get_available_mentors
|
48
|
+
def get_available_mentors
|
49
|
+
url = "#{@api_base_path}/users/available_mentors"
|
50
|
+
handle_timeouts do
|
51
|
+
response = self.class.get(url, headers: auth_header)
|
52
|
+
convert_response(response, "user")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Get user availability
|
57
|
+
#
|
58
|
+
# @param id [Integer] A user id.
|
59
|
+
# @return [HTTParty::Response] User availability.
|
60
|
+
# @example Get user availability
|
61
|
+
# Spartacus#get_availability
|
62
|
+
def get_availability(id)
|
63
|
+
url = "#{@api_base_path}/users/#{id}/availability"
|
64
|
+
handle_timeouts do
|
65
|
+
self.class.get(url, headers: auth_header)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Get user enrollments
|
70
|
+
#
|
71
|
+
# @param id [Integer] A user id.
|
72
|
+
# @return [HTTParty::Response] User enrollments.
|
73
|
+
# @example Get user enrollments
|
74
|
+
# Spartacus#get_enrollments
|
75
|
+
def get_enrollments(id)
|
76
|
+
url = "#{@api_base_path}/users/#{id}/enrollments"
|
77
|
+
handle_timeouts do
|
78
|
+
self.class.get(url, headers: auth_header)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Get user accomplishments
|
83
|
+
#
|
84
|
+
# @param id [Integer] A user id.
|
85
|
+
# @return [HTTParty::Response] User accomplishments.
|
86
|
+
# @example Get user accomplishments
|
87
|
+
# Spartacus#get_accomplishments
|
88
|
+
def get_accomplishments(id)
|
89
|
+
url = "#{@api_base_path}/users/#{id}/accomplishments"
|
90
|
+
handle_timeouts do
|
91
|
+
self.class.get(url, headers: auth_header)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Mark user's current enrollment as onboarded
|
96
|
+
#
|
97
|
+
# @param id [Integer] A user id.
|
98
|
+
# @return [HTTParty::Response] Succes or failure message.
|
99
|
+
# @example Onboard user
|
100
|
+
# Spartacus#onboard
|
101
|
+
def onboard(id)
|
102
|
+
url = "#{@api_base_path}/users/#{id}/onboard"
|
103
|
+
handle_timeouts do
|
104
|
+
self.class.post(url, headers: auth_header)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Update the user's password
|
109
|
+
#
|
110
|
+
# @param id [Integer] A user id.
|
111
|
+
# @param password [String] User password.
|
112
|
+
# @return [User] Updated user.
|
113
|
+
# @example Update user password
|
114
|
+
# Spartacus#update_password
|
115
|
+
def update_password(id, password)
|
116
|
+
url = "#{@api_base_path}/users/#{id}/update_password"
|
117
|
+
handle_timeouts do
|
118
|
+
response = self.class.put(url, headers: auth_header,
|
119
|
+
query: { user: { password: password,
|
120
|
+
confirmation: password } })
|
121
|
+
convert_response(response, "user")
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Update a user
|
127
|
+
#
|
128
|
+
# @param id [Integer] A user id.
|
129
|
+
# @param options [Hash] A customizable set of options.
|
130
|
+
# @option options [String] :email User email.
|
131
|
+
# @option options [String] :first_name User first_name.
|
132
|
+
# @option options [String] :last_name User last name.
|
133
|
+
# @option options [String] :twitter_handle User Twitter handle.
|
134
|
+
# @option options [String] :dribbble_handle User Dribbble handle.
|
135
|
+
# @option options [String] :github_handle User GitHub handle.
|
136
|
+
# @option options [String] :codecademy_handle User Codecademy handle.
|
137
|
+
# @option options [String] :linkedin User LinkIn profile.
|
138
|
+
# @option options [String] :time_zone User time zone
|
139
|
+
# @option options [String] :bio User biography.
|
140
|
+
# @option options [String] :name User fullname.
|
141
|
+
# @option options [String] :photo User photo.
|
142
|
+
# @option options [String] :os User operating system.
|
143
|
+
# @option options [Boolean] :dismissed_holiday_freeze User dismissed
|
144
|
+
# holiday freeze.
|
145
|
+
# @option options [String] :title User title.
|
146
|
+
# @option options [String] :lead_mentor_account User lead mentor account.
|
147
|
+
# @option options [String] :password User password.
|
148
|
+
# @option options [String] :password_confirmation User password confirmation.
|
149
|
+
# @option options [Boolean] :remember_me Remeber user.
|
150
|
+
# @option options [String] :facebook_id User Facebook ID.
|
151
|
+
# @option options [String] :stripe_customer_id User Stripe customer ID.
|
152
|
+
# @option options [String] :stripe_token User Stripe token.
|
153
|
+
# @option options [String] :skype_handle User Skype handle.
|
154
|
+
# @option options [String] :referral_token User referral token.
|
155
|
+
# @option options [Boolean] :send_new_message_emails Send user new emails.
|
156
|
+
# @option options [String] :referred_by_id User referred by ID.
|
157
|
+
# @option options [String] :google_plus_id User GooglePlus ID.
|
158
|
+
# @option options [Boolean] :private_profile Set user profile to private.
|
159
|
+
# @option options [Integer] :quota User student quota.
|
160
|
+
# @option options [Integer] :quota_limit User student quota limit.
|
161
|
+
# @option options [Integer] :first_visit_id User first visit ID.
|
162
|
+
# @option options [Integer] :crm_lead_id User CRM lead ID.
|
163
|
+
# @option options [String] :phone_num User phone number.
|
164
|
+
# @option options [String] :role User role.
|
165
|
+
# @option options [Integer] :student_profile User student profile.
|
166
|
+
# @option options [String] :tos
|
167
|
+
# @return [User] The updated user.
|
168
|
+
# @example Update a user's data
|
169
|
+
# Spartacus#update_user_data(129, {how_heard: 'On the Googles'})
|
170
|
+
def update_user(id, options={})
|
171
|
+
whitelist = ['email','first_name','last_name','twitter_handle',
|
172
|
+
'dribbble_handle','github_handle','codecademy_handle',
|
173
|
+
'linkedin','time_zone','bio','name','photo','os',
|
174
|
+
'dismissed_holiday_freeze','title','lead_mentor_account',
|
175
|
+
'password','password_confirmation','remember_me','facebook_id',
|
176
|
+
'stripe_customer_id','stripe_token','skype_handle',
|
177
|
+
'referral_token','send_new_message_emails','referred_by_id',
|
178
|
+
'google_plus_id','private_profile','quota','quota_limit',
|
179
|
+
'first_visit_id','crm_lead_id','phone_num','role',
|
180
|
+
'student_profile','tos']
|
181
|
+
|
182
|
+
options = convert_keys(options)
|
183
|
+
user_params = whitelist_params(options, whitelist)
|
184
|
+
url = "#{@api_base_path}/users/#{id}"
|
185
|
+
|
186
|
+
handle_timeouts do
|
187
|
+
response = self.class.put(url, headers: auth_header,
|
188
|
+
query: { user: user_params })
|
189
|
+
convert_response(response, "User")
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Update a user's data
|
194
|
+
#
|
195
|
+
# @param id [Integer] A user id.
|
196
|
+
# @param options [Hash] A customizable set of options.
|
197
|
+
# @option options [String] :how_heard How user heard about Bloc.
|
198
|
+
# @option options [String] :how_heard_details How user heard about Bloc details.
|
199
|
+
# @option options [String] :how_paid How user paid for Bloc.
|
200
|
+
# @option options [String] :how_paid_details How user paid for Bloc details.
|
201
|
+
# @return [UserData] The updated user data.
|
202
|
+
# @example Update a user's data
|
203
|
+
# Spartacus#update_user_data(129, {how_heard: 'On the Googles'})
|
204
|
+
def update_user_data(id, options={})
|
205
|
+
whitelist = ['how_heard', 'how_heard_details', 'how_paid', 'how_paid_details']
|
206
|
+
|
207
|
+
options = convert_keys(options)
|
208
|
+
user_data_params = whitelist_params(options, whitelist)
|
209
|
+
url = "#{@api_base_path}/users/#{id}/update_user_data"
|
210
|
+
|
211
|
+
handle_timeouts do
|
212
|
+
response = self.class.put(url, headers: auth_header,
|
213
|
+
query: { user_data: user_data_params })
|
214
|
+
convert_response(response, "UserData")
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def replace_availability(id, time_slots={})
|
219
|
+
end
|
220
|
+
end
|
data/spartacus.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'spartacus'
|
3
|
+
s.version = '0.2.0 '
|
4
|
+
s.files = `git ls-files`.split($\)
|
5
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
6
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
7
|
+
s.require_paths = ["lib"]
|
8
|
+
s.date = '2015-09-25'
|
9
|
+
s.summary = 'A client for the Bloc AP'
|
10
|
+
s.description = 'A client for the Bloc API'
|
11
|
+
s.authors = ['Ben Neely']
|
12
|
+
s.email = 'ben@bloc.to'
|
13
|
+
s.homepage = 'http://rubygems.org/gems/spartacus'
|
14
|
+
s.license = 'MIT'
|
15
|
+
s.add_runtime_dependency 'httparty', '~>0.13.7'
|
16
|
+
s.add_runtime_dependency 'activesupport', '~>4.2'
|
17
|
+
s.add_runtime_dependency 'json', '~>1.8'
|
18
|
+
s.add_development_dependency "bundler"
|
19
|
+
s.add_development_dependency "rspec"
|
20
|
+
s.add_development_dependency "rake"
|
21
|
+
end
|
data/spec/.keep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spartacus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Neely
|
@@ -52,13 +52,68 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '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: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
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'
|
55
97
|
description: A client for the Bloc API
|
56
98
|
email: ben@bloc.to
|
57
99
|
executables: []
|
58
100
|
extensions: []
|
59
101
|
extra_rdoc_files: []
|
60
102
|
files:
|
103
|
+
- Gemfile
|
104
|
+
- Gemfile.lock
|
105
|
+
- LICENSE
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/client/alumni_stories.rb
|
109
|
+
- lib/client/base_client.rb
|
110
|
+
- lib/client/checkpoints.rb
|
111
|
+
- lib/client/class_factory.rb
|
112
|
+
- lib/client/roadmap_sections.rb
|
113
|
+
- lib/client/users.rb
|
61
114
|
- lib/spartacus.rb
|
115
|
+
- spartacus.gemspec
|
116
|
+
- spec/.keep
|
62
117
|
homepage: http://rubygems.org/gems/spartacus
|
63
118
|
licenses:
|
64
119
|
- MIT
|
@@ -83,5 +138,6 @@ rubygems_version: 2.4.8
|
|
83
138
|
signing_key:
|
84
139
|
specification_version: 4
|
85
140
|
summary: A client for the Bloc AP
|
86
|
-
test_files:
|
141
|
+
test_files:
|
142
|
+
- spec/.keep
|
87
143
|
has_rdoc:
|