strongmind-schoology-client 0.1.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
+ SHA256:
3
+ metadata.gz: 159bb005234f79cb05952d04e5c8df61ea13c93d39947bf324803faf291a3f43
4
+ data.tar.gz: '06921f258d447fa3c5a11eddba6887b3edceb52c009af251773d908954de0796'
5
+ SHA512:
6
+ metadata.gz: 32eba4f569170e2e4ab5046b933a83e4f03caa3c5ce787f05d1a69772e1ae8c2f9bbca039dc5378c82d43a29d3f0830bce661806a54bc48b3ae7054fd9e96f43
7
+ data.tar.gz: 7ce82c65442e995394e9b006d12b57f14b5e08769c129f0b29ab5f66311eefda5bfd351ee776abfbb883730dd079c575638d8937cb54e679da1ee102f7a5aad8
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-04-28
4
+
5
+ - Initial release
data/CODEOWNERS ADDED
@@ -0,0 +1,6 @@
1
+ # This File was Automatically generated by Devops
2
+ # The first few lines should be consistant across all repos
3
+ /.github/* @StrongMind/binary-ops
4
+ /infrastructure/* @StrongMind/binary-ops
5
+
6
+ * @StrongMind/qwerty-talkers
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in schoology.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ schoology (0.1.0)
5
+ faraday
6
+ faraday_middleware
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.0)
13
+ faraday (1.10.3)
14
+ faraday-em_http (~> 1.0)
15
+ faraday-em_synchrony (~> 1.0)
16
+ faraday-excon (~> 1.1)
17
+ faraday-httpclient (~> 1.0)
18
+ faraday-multipart (~> 1.0)
19
+ faraday-net_http (~> 1.0)
20
+ faraday-net_http_persistent (~> 1.0)
21
+ faraday-patron (~> 1.0)
22
+ faraday-rack (~> 1.0)
23
+ faraday-retry (~> 1.0)
24
+ ruby2_keywords (>= 0.0.4)
25
+ faraday-em_http (1.0.0)
26
+ faraday-em_synchrony (1.0.0)
27
+ faraday-excon (1.1.0)
28
+ faraday-httpclient (1.0.1)
29
+ faraday-multipart (1.0.4)
30
+ multipart-post (~> 2)
31
+ faraday-net_http (1.0.1)
32
+ faraday-net_http_persistent (1.2.0)
33
+ faraday-patron (1.0.0)
34
+ faraday-rack (1.0.0)
35
+ faraday-retry (1.0.3)
36
+ faraday_middleware (1.2.0)
37
+ faraday (~> 1.0)
38
+ json (2.6.3)
39
+ multipart-post (2.3.0)
40
+ parallel (1.23.0)
41
+ parser (3.2.2.1)
42
+ ast (~> 2.4.1)
43
+ rainbow (3.1.1)
44
+ rake (13.0.6)
45
+ regexp_parser (2.8.0)
46
+ rexml (3.2.5)
47
+ rspec (3.12.0)
48
+ rspec-core (~> 3.12.0)
49
+ rspec-expectations (~> 3.12.0)
50
+ rspec-mocks (~> 3.12.0)
51
+ rspec-core (3.12.2)
52
+ rspec-support (~> 3.12.0)
53
+ rspec-expectations (3.12.3)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.12.0)
56
+ rspec-mocks (3.12.5)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.12.0)
59
+ rspec-support (3.12.0)
60
+ rubocop (1.50.2)
61
+ json (~> 2.3)
62
+ parallel (~> 1.10)
63
+ parser (>= 3.2.0.0)
64
+ rainbow (>= 2.2.2, < 4.0)
65
+ regexp_parser (>= 1.8, < 3.0)
66
+ rexml (>= 3.2.5, < 4.0)
67
+ rubocop-ast (>= 1.28.0, < 2.0)
68
+ ruby-progressbar (~> 1.7)
69
+ unicode-display_width (>= 2.4.0, < 3.0)
70
+ rubocop-ast (1.28.0)
71
+ parser (>= 3.2.1.0)
72
+ ruby-progressbar (1.13.0)
73
+ ruby2_keywords (0.0.5)
74
+ unicode-display_width (2.4.2)
75
+
76
+ PLATFORMS
77
+ x86_64-darwin-20
78
+ x86_64-darwin-21
79
+
80
+ DEPENDENCIES
81
+ rake (~> 13.0)
82
+ rspec (~> 3.0)
83
+ rubocop (~> 1.21)
84
+ schoology!
85
+
86
+ BUNDLED WITH
87
+ 2.3.6
data/README.md ADDED
@@ -0,0 +1,146 @@
1
+
2
+ # Example README
3
+
4
+ This is an example of what we expect in a README.
5
+
6
+ ## What?
7
+
8
+ A summary of the purpose of this piece of software, for example:
9
+ Delivery of Learnosity assessments to students and reporting student results to teachers.
10
+
11
+ ### Diagram
12
+
13
+ A diagram showing all of the following:
14
+
15
+ * project inputs
16
+ * projects end users
17
+ * project outputs
18
+ * project data stores
19
+
20
+ ([see mermaid documentation on how to create these diagrams](https://mermaid-js.github.io/mermaid/#/./flowchart?id=flowcharts-basic-syntax))
21
+
22
+ For example:
23
+
24
+ ```mermaid
25
+ graph LR
26
+ subgraph project_components[Hypothetical Service]
27
+
28
+ project_api[Hypothetical Service API]
29
+ project_frontend[Hypothetical Service Frontend]
30
+ subgraph datastores[Data Stores]
31
+ postgres[PostgreSQL]
32
+ queue[SQS queue service]
33
+ end
34
+ end
35
+
36
+ subgraph inputs[Inputs]
37
+ event_platform_input[Event Platform]
38
+ cloud_canvas[Cloud Canvas API]
39
+ identity[Identity Server]
40
+ end
41
+
42
+
43
+ subgraph end_users[End Users]
44
+ student[Student]
45
+ administrator[Administrator]
46
+ end
47
+
48
+ subgraph outputs[Outputs]
49
+ event_platform_out[Event Platform]
50
+ end
51
+
52
+ event_platform_input -->|Canvas Change Events| project_api
53
+ cloud_canvas -->|Canvas User API get| project_api
54
+ identity -->|Authentication of users| project_frontend
55
+
56
+ project_frontend -->|Views a thing| student
57
+ administrator -->|Creates things| project_frontend
58
+
59
+ project_api -->|Sends create and view messages| event_platform_out
60
+
61
+ ```
62
+
63
+ ## Where?
64
+
65
+ ### Links
66
+
67
+ A list of links to deployed software
68
+ For example:
69
+
70
+ * dev: [dev.strongmind.com](https://dev.strongmind.com)
71
+ * prod: [strongmind.com](https://strongmind.com)
72
+
73
+ ### CI/CD
74
+
75
+ A link to CI/CD for this repository
76
+ For example:
77
+
78
+ * [https://github.com/StrongMind/culture/actions](https://github.com/StrongMind/culture/actions)
79
+
80
+ ### Administration
81
+
82
+ A list of links to operational information, for example:
83
+
84
+ * [Logs](https://us-west-2.console.aws.amazon.com/cloudwatch/home?region=us-west-2#logsV2:logs-insights$3FqueryDetail$%5B%E2%80%A6%5D*2flambda*2fid-mapper-prod$2529$2529)
85
+ * [Exception Tracking](https://sentry.io/organizations/strongmind-4j/projects/id-mapper/?project=6262579)
86
+ * [Monitoring & Metrics Dashboard](https://us-west-2.console.aws.amazon.com/cloudwatch/home?region=us-west-2#dashboards:name=identifier-mapper-prod)
87
+
88
+ ## Local Install
89
+
90
+ A set of comprehensive instructions to install from scratch on a developer workstation. We suggest you test these with a member from another team. For example:
91
+
92
+ ### Mac
93
+
94
+ In this source directory:
95
+
96
+ 1. Install homebrew
97
+ 1. Install python 3.10 using homebrew `brew install python@3.10`
98
+ 1. Install virtualenv and virtualenvwrapper `pip install virtualenv virtualenvwrapper`
99
+ 1. Create virtual environment for project `mkvirtualenv project_name -p /opt/homebrew/opt/python@3.10/bin/python3`
100
+ 1. Install project requirements `pip install -r requirements.txt`
101
+
102
+ #### Known Issues and Fixes
103
+
104
+ If your system python does not include pip, you will need to make sure pip is installed :
105
+
106
+ ```console
107
+ python -m ensurepip # if your system python is at least 3.4
108
+ ```
109
+
110
+ If your system python isn't at least 3.4, you will need to use your system package manager to install pip.
111
+
112
+ ### Windows
113
+
114
+ In this source directory:
115
+
116
+ 1. [Install python](https://www.python.org/downloads/release/python-3105/)
117
+ 1. Open project in pycharm
118
+ 1. Set interpreter installed python 3.10
119
+ 1. Open shell
120
+ 1. Install project requirements `pip install -r requirements.txt`
121
+
122
+ ## Run tests locally
123
+
124
+ A set of instructions to run tests locally, for example:
125
+
126
+ ```console
127
+ pytest
128
+ ```
129
+
130
+ ## Run service locally
131
+
132
+ A set of instructions to run service locally, for example:
133
+
134
+ ### Mac (service)
135
+
136
+ ```console
137
+ python manage.py runserver
138
+ ```
139
+
140
+ ### Windows (service)
141
+
142
+ ```console
143
+ py manage.py runserver
144
+ ```
145
+
146
+ > Code owners can be found in [CODEOWNERS file](./CODEOWNERS)
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SchoologyClient
4
+ class Client
5
+ BASE_URL = "https://schoologysandbox.schoology.com/v1"
6
+
7
+ attr_reader :oauth_token, :adapter
8
+
9
+ def initialize(oauth_token:, adapter: Faraday.default_adapter, stubs: nil)
10
+ @oauth_token = oauth_token
11
+ @adapter = adapter
12
+ #used for tests
13
+ @stubs = stubs
14
+ end
15
+
16
+ def group
17
+ GroupResource.new(self)
18
+ end
19
+
20
+ def connection
21
+ @connection ||= Faraday.new(BASE_URL) do |conn|
22
+ conn.request :authorization, :Bearer, oauth_token
23
+ conn.request :json
24
+
25
+ conn.response :dates
26
+ conn.response :json, content_type: "application/json"
27
+
28
+ conn.adapter adapter, @stubs
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,19 @@
1
+ require "ostruct"
2
+
3
+ module SchoologyClient
4
+ class Object < OpenStruct
5
+ def initialize(attributes)
6
+ super to_ostruct(attributes)
7
+ end
8
+
9
+ def to_ostruct(obj)
10
+ if obj.is_a?(Hash)
11
+ OpenStruct.new(obj.map { |key, val| [key, to_ostruct(val)] }.to_h)
12
+ elsif obj.is_a?(Array)
13
+ obj.map { |o| to_ostruct(o) }
14
+ else # Assumed to be a primitive value
15
+ obj
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module SchoologyClient
2
+ class Group < Object
3
+ end
4
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SchoologyClient
4
+ class Resource
5
+ attr_reader :client
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def post_request(url, body:, headers: {})
12
+ handle_response client.connection.post(url, body, headers)
13
+ end
14
+
15
+ def handle_response(response)
16
+ case response.status
17
+ when 400
18
+ raise Error, "Your request was malformed. #{response.body["error"]}"
19
+ when 401
20
+ raise Error, "You did not supply valid authentication credentials. #{response.body["error"]}"
21
+ when 403
22
+ raise Error, "You are not allowed to perform that action. #{response.body["error"]}"
23
+ when 404
24
+ raise Error, "No results were found for your request. #{response.body["error"]}"
25
+ when 429
26
+ raise Error, "Your request exceeded the API rate limit. #{response.body["error"]}"
27
+ when 500
28
+ raise Error, "We were unable to perform the request due to server-side problems. #{response.body["error"]}"
29
+ when 503
30
+ raise Error, "You have been rate limited for sending more than 20 requests per second. #{response.body["error"]}"
31
+ end
32
+
33
+ response
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SchoologyClient
4
+ class GroupResource < Resource
5
+ def create(**attributes)
6
+ GroupResource.new post_request("groups", body: attributes).body
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SchoologyClient
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday_middleware"
5
+ require_relative "schoology-client/version"
6
+
7
+ module SchoologyClient
8
+ autoload :Client, "schoology-client/client"
9
+ autoload :Object, "schoology-client/object"
10
+ autoload :Resource, "schoology-client/resource"
11
+
12
+ # High-level categories of Schoology API calls
13
+ autoload :GroupResource, "schoology-client/resources/group"
14
+
15
+ # Classes used to return a nicer object wrapping the response data
16
+ autoload :Group, "schoology/objects/group"
17
+ end
data/sig/schoology.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Schoology
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strongmind-schoology-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Strongmind
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - qwertytalk@strongmind.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - CODEOWNERS
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - README.md
55
+ - Rakefile
56
+ - lib/schoology-client.rb
57
+ - lib/schoology-client/client.rb
58
+ - lib/schoology-client/object.rb
59
+ - lib/schoology-client/objects/group.rb
60
+ - lib/schoology-client/resource.rb
61
+ - lib/schoology-client/resources/group.rb
62
+ - lib/schoology-client/version.rb
63
+ - sig/schoology.rbs
64
+ homepage: https://github.com/Strongmind/schoology-client
65
+ licenses: []
66
+ metadata:
67
+ allowed_push_host: https://rubygems.org/
68
+ homepage_uri: https://github.com/Strongmind/schoology-client
69
+ source_code_uri: https://github.com/Strongmind/schoology-client
70
+ changelog_uri: https://github.com/Strongmind/schoology-client
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.6.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.3.5
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: API wrapper for Schoology LMS API
90
+ test_files: []