bloc_records 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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/records.rb +63 -0
  3. data/lib/roadmap.rb +17 -0
  4. metadata +73 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50cb100f761c1c688a4209fc6446d8c95873b54e
4
+ data.tar.gz: 78d68761fbc8b7b9dd1587e388e8c07858cb5f5a
5
+ SHA512:
6
+ metadata.gz: f273854a09fc2e3a98ac9422af8dcd2b2263d6b8d78d98d2cf595cc1b0f77532cd7b07071fec5d59fa6716ef1a726e0dab0100b5f9fe189b8b371638cb673a36
7
+ data.tar.gz: 3eb19b93f0261b699a3482e13a87cb475726f301d8f2fec1abe8804dbb5914ac3e3201629f54e3cf02e941eaca23f2f1a7c5a940834741d650cf4ba4b38bd5f2
data/lib/records.rb ADDED
@@ -0,0 +1,63 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require './lib/roadmap'
4
+
5
+ class MyRecords
6
+ include HTTParty
7
+ include Roadmap
8
+
9
+ def initialize(email, password)
10
+ @base_url = 'https://www.bloc.io/api/v1'
11
+ response = self.class.post(@base_url + '/sessions', body:
12
+ {"email": email, "password": password})
13
+ raise "Invalid credentials." if response.code != 200
14
+ @auth_token = response["auth_token"]
15
+ end
16
+
17
+ def get_me
18
+ response = self.class.get(@base_url + '/users/me', headers:
19
+ { "authorization" => @auth_token })
20
+ data = JSON.parse(response.body)
21
+ data
22
+ end
23
+
24
+ def get_mentor_availability(mentor_id)
25
+ id = mentor_id.to_s
26
+ response = self.class.get(@base_url + '/mentors/' + id +
27
+ '/student_availability', headers: { "authorization" => @auth_token })
28
+ slots = JSON.parse(response.body)
29
+ slots
30
+ end
31
+
32
+ def get_messages(page = nil)
33
+ page.nil? ? page = '' : page = page.to_s
34
+ response = self.class.get(@base_url + '/message_threads' + page,
35
+ headers: { "authorization" => @auth_token })
36
+ messages = JSON.parse(response.body)
37
+ messages
38
+ end
39
+
40
+ def create_message(sender, recipient_id, token = nil, subject = nil, stripped_text)
41
+ response = self.class.post(@base_url + '/messages', body:
42
+ {"sender": sender, "recipient_id": recipient_id, "token": token,
43
+ "subject": subject, "stripped-text": stripped_text}, headers:
44
+ { "authorization" => @auth_token})
45
+ response
46
+ end
47
+
48
+ def create_submission(assignment_branch, assignment_commit_link, checkpoint_id, comment, enrollment_id)
49
+ response = self.class.post(@base_url + '/checkpoint_submissions', body:
50
+ {"assignment_branch": assignment_branch, "assignment_commit_link": assignment_commit_link,
51
+ "checkpoint_id": checkpoint_id, "comment": comment, "enrollment_id": enrollment_id}, headers:
52
+ { "authorization" => @auth_token })
53
+ response
54
+ end
55
+
56
+ def update_submission(id, assignment_branch, assignment_commit_link, checkpoint_id, comment, enrollment_id)
57
+ response = self.class.put(@base_url + '/checkpoint_submissions/' + id, body:
58
+ {"id": id, "assignment_branch": assignment_branch, "assignment_commit_link": assignment_commit_link,
59
+ "checkpoint_id": checkpoint_id, "comment": comment, "enrollment_id": enrollment_id}, headers:
60
+ { "authorization" => @auth_token })
61
+ response
62
+ end
63
+ end
data/lib/roadmap.rb ADDED
@@ -0,0 +1,17 @@
1
+ module Roadmap
2
+ def get_roadmap(roadmap_id)
3
+ id = roadmap_id.to_s
4
+ response = self.class.get(@base_url + '/roadmaps/' + id,
5
+ headers: { "authorization" => @auth_token })
6
+ roadmap = JSON.parse(response.body)
7
+ roadmap
8
+ end
9
+
10
+ def get_checkpoint(checkpoint_id)
11
+ id = checkpoint_id.to_s
12
+ response = self.class.get(@base_url + '/checkpoints/' + id,
13
+ headers: { "authorization" => @auth_token })
14
+ checkpoint = JSON.parse(response.body)
15
+ checkpoint
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bloc_records
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sean Robenalt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-24 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
+ description: A client for the Bloc API
42
+ email: seanaltonrobenalt@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/records.rb
48
+ - lib/roadmap.rb
49
+ homepage: http://rubygems.org/gems/bloc_records
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.6.12
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Bloc Records
73
+ test_files: []