kele_wyll 0.0.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 +7 -0
- data/lib/kele_wyll.rb +95 -0
- data/lib/roadmap.rb +23 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ddbb8dd622cbaaac5985befc2d41dabc6aa02b0d805a0f8c94fba0824420d8b8
|
4
|
+
data.tar.gz: 76127c59da07ef1431d91e4ef3728516ca79a9fe9eebcb2e296b422664ede587
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6667d95b2319b753b959e7f77adfc265c1f0ffd46753fea90a720aca3c335cbc5ecfbe4ad938498766495634e477145f5de6163151b83c38c6ac2bd63fd8ec6c
|
7
|
+
data.tar.gz: cbd2cda95242dad9d39dad668f023d99530006f82489008b7c03413c3b604c155b8917ddc0c8328919e6d672869843c004e955512585c8f7ff68ba8462875060
|
data/lib/kele_wyll.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
require './lib/roadmap'
|
4
|
+
|
5
|
+
class Kele
|
6
|
+
include HTTParty
|
7
|
+
include Roadmap
|
8
|
+
|
9
|
+
base_uri 'https://www.bloc.io/api/v1'
|
10
|
+
|
11
|
+
def initialize(email, password)
|
12
|
+
@email = email
|
13
|
+
|
14
|
+
response = self.class.post('/sessions', body: {
|
15
|
+
email: @email,
|
16
|
+
password: password
|
17
|
+
})
|
18
|
+
|
19
|
+
if response.success?
|
20
|
+
@auth_token = response['auth_token']
|
21
|
+
@enrollment_id = get_me["current_enrollment"]["id"]
|
22
|
+
@mentor_id = get_me["current_enrollment"]["mentor_id"]
|
23
|
+
else
|
24
|
+
raise "Invalid username or password. Please try again"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_me
|
29
|
+
response = self.class.get('/users/me', headers: { "authorization" => @auth_token })
|
30
|
+
|
31
|
+
if response.success?
|
32
|
+
JSON.parse(response.body)
|
33
|
+
else
|
34
|
+
raise response.response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_mentor_availability
|
39
|
+
response = self.class.get("/mentors/#{@mentor_id}/student_availability", headers: { "authorization" => @auth_token })
|
40
|
+
|
41
|
+
if response.success?
|
42
|
+
JSON.parse(response.body)
|
43
|
+
else
|
44
|
+
raise response.response
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_messages(page_number=0)
|
49
|
+
if page_number == 0
|
50
|
+
url = "/message_threads"
|
51
|
+
response = self.class.get(url, headers: { "authorization" => @auth_token })
|
52
|
+
else
|
53
|
+
url = "/message_threads?page=#{page_number}"
|
54
|
+
response = self.class.get(url, headers: { "authorization" => @auth_token }, body: { page: page_number })
|
55
|
+
end
|
56
|
+
|
57
|
+
if response.success?
|
58
|
+
JSON.parse(response.body)
|
59
|
+
else
|
60
|
+
raise response.response
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_message(subject, text, recipient=@mentor_id)
|
65
|
+
response = self.class.post("/messages", headers: { "authorization" => @auth_token }, body: {
|
66
|
+
"sender" => @email,
|
67
|
+
"recipient_id" => recipient,
|
68
|
+
"subject" => subject,
|
69
|
+
"stripped-text" => text
|
70
|
+
})
|
71
|
+
|
72
|
+
if response.success?
|
73
|
+
"Message sent."
|
74
|
+
else
|
75
|
+
raise "There was and error sending the message. Please try again."
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_submission(checkpoint_id, assignment_branch, assignment_commit_link, comment)
|
80
|
+
response = self.class.post("/checkpoint_submissions", headers: { "authorization" => @auth_token }, body: {
|
81
|
+
"checkpoint_id" => checkpoint_id,
|
82
|
+
"assignment_branch" => assignment_branch,
|
83
|
+
"assignment_commit_link" => assignment_commit_link,
|
84
|
+
"comment" => comment,
|
85
|
+
"enrollment_id" => @enrollment_id
|
86
|
+
})
|
87
|
+
|
88
|
+
if response.success?
|
89
|
+
"Checkpoint submitted."
|
90
|
+
else
|
91
|
+
raise "There was and error submitting the checkpoint. Please try again."
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/lib/roadmap.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Roadmap
|
2
|
+
def get_roadmap(roadmap_id)
|
3
|
+
#example use 38
|
4
|
+
response = self.class.get("/roadmaps/#{roadmap_id}", headers: { "authorization" => @auth_token })
|
5
|
+
|
6
|
+
if response.success?
|
7
|
+
@roadmap = JSON.parse(response.body)
|
8
|
+
else
|
9
|
+
raise response.response
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_checkpoint(checkpoint_id)
|
14
|
+
# example use 2481
|
15
|
+
response = self.class.get("/checkpoints/#{checkpoint_id}", headers: { "authorization" => @auth_token })
|
16
|
+
|
17
|
+
if response.success?
|
18
|
+
@checkpoint = JSON.parse(response.body)
|
19
|
+
else
|
20
|
+
raise response.response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kele_wyll
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Natalie Wyll
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-13 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: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
description: A client for the Bloc API
|
42
|
+
email: nataliewyll@yahoo.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/kele_wyll.rb
|
48
|
+
- lib/roadmap.rb
|
49
|
+
homepage: http://rubygems.org/gems/kele_wyll
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 2.7.3
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: Kele API Client
|
73
|
+
test_files: []
|