strongmind-schoology-client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56a2628a8f8dda5eae583876c5310a1284d904360240ed625004b24fcf59c6b7
4
- data.tar.gz: a6b8340d998bf65d6c17b33d3c2764eee3d027e9511ed3389f7bb13d005222ab
3
+ metadata.gz: 271745541c3bb94e1ef9eded32dd55cf25bc3d78913b02214244f33ac2fb1456
4
+ data.tar.gz: d2b1548b934b5cd2779864d22ce82417b6438eae8d6081b8e45f96f5eaf1a8ce
5
5
  SHA512:
6
- metadata.gz: 9708c7c9a7db17cda211539aee89cb122a56d8934aa309351aa54969edeb72b04cb7dae5fcf20ff426c401ffad1748cfb16237c27b3e630b962c67ecd526a19d
7
- data.tar.gz: 7a254abdd176875275c775e9d648c44d8f86fd77a540a4334eb58daee1ab7568139f576aa4521ddb509e581358d0345647aaa16b844e966009f65749bebeb441
6
+ metadata.gz: fc5cebfd760eb646c78e27693524e651dd90b63516f77d58df9c1f0bce382bf27028948504fdb63aa7e4d5d7ca572507efd3abd6f8134f816696d181e5cd4a97
7
+ data.tar.gz: 78bd3b4d61b96a38338ee5af1a554ac0cd1e199634d589eaf63963a2462893d975cdec52eb2773e1803bfeaf91783d1b7b2544a32ef97f3bc518fb38946dd93f
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strongmind-schoology-client (0.1.0)
5
- faraday (~> 1.x)
4
+ strongmind-schoology-client (0.1.2)
5
+ faraday (~> 1.1)
6
6
  faraday_middleware (~> 1.2)
7
7
  oauth (~> 1.1)
8
- pry
9
- rails (~> 7.x)
8
+ rails (~> 7.0)
9
+ railties (~> 7.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
@@ -78,7 +78,6 @@ GEM
78
78
  tzinfo (~> 2.0)
79
79
  ast (2.4.2)
80
80
  builder (3.2.4)
81
- coderay (1.1.3)
82
81
  concurrent-ruby (1.2.2)
83
82
  crass (1.0.6)
84
83
  date (3.3.3)
@@ -138,8 +137,6 @@ GEM
138
137
  net-smtp (0.3.3)
139
138
  net-protocol
140
139
  nio4r (2.5.9)
141
- nokogiri (1.14.3-arm64-darwin)
142
- racc (~> 1.4)
143
140
  nokogiri (1.14.3-x86_64-darwin)
144
141
  racc (~> 1.4)
145
142
  oauth (1.1.0)
@@ -151,9 +148,6 @@ GEM
151
148
  parallel (1.23.0)
152
149
  parser (3.2.2.1)
153
150
  ast (~> 2.4.1)
154
- pry (0.14.2)
155
- coderay (~> 1.1)
156
- method_source (~> 1.0)
157
151
  racc (1.6.2)
158
152
  rack (2.2.7)
159
153
  rack-test (2.1.0)
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+ require 'oauth'
5
+
6
+ module SchoologyClient
7
+ class Client
8
+ attr_reader :adapter, :oauth_consumer_key, :oauth_consumer_secret, :url, :stubs
9
+
10
+ def initialize(adapter: Faraday.default_adapter, stubs: nil)
11
+ @adapter = adapter
12
+ @oauth_consumer_key = SchoologyClient.configuration.oauth_consumer_key
13
+ @oauth_consumer_secret = SchoologyClient.configuration.oauth_consumer_secret
14
+ @url = SchoologyClient.configuration.url
15
+
16
+ #used for specs
17
+ @stubs = stubs
18
+ end
19
+
20
+ def group
21
+ GroupResource.new(self)
22
+ end
23
+
24
+ def connection
25
+
26
+ # Set up the OAuth 1.0 consumer
27
+ consumer = OAuth::Consumer.new(
28
+ @oauth_consumer_key,
29
+ @oauth_consumer_secret,
30
+ site: @url,
31
+ scheme: :header,
32
+ signature_method: 'PLAINTEXT',
33
+ realm: 'Schoology API'
34
+ )
35
+
36
+ # Set up the Faraday connection
37
+ connection = Faraday.new("#{@url}") do |conn|
38
+ conn.request :url_encoded
39
+ conn.request :json
40
+
41
+ conn.response :dates
42
+ conn.response :json, content_type: "application/json"
43
+
44
+ if @stubs
45
+ conn.adapter adapter, @stubs
46
+ else
47
+ conn.adapter adapter
48
+ end
49
+ end
50
+
51
+ return connection
52
+ end
53
+
54
+ end
55
+ end
56
+
@@ -0,0 +1,12 @@
1
+ module SchoologyClient
2
+ class Configuration
3
+ attr_accessor :oauth_consumer_key, :oauth_consumer_secret, :url
4
+
5
+ def initialize
6
+ @oauth_consumer_key = nil
7
+ @oauth_consumer_secret = nil
8
+ @url = nil
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generatorsi'
4
+ require 'schoology_client'
5
+
6
+ module SchoologyApi
7
+ module Generators
8
+ class InstallGenerator < Rails::Generators::Base
9
+ source_root File.expand_path("../../templates", __FILE__)
10
+
11
+ desc "Generate SchoologyClient initializer file for Rails applications"
12
+
13
+ def copy_initializer
14
+ template "schoology_api.rb", "config/initializers/schoology_api.rb"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'json'
3
+
4
+ module SchoologyClient
5
+ class GroupResource < Resource
6
+ def create(**attributes)
7
+ response_body = post_request("groups", body: attributes.to_json).body
8
+ return GroupResource.new(response_body)
9
+ end
10
+ end
11
+ end
12
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SchoologyClient
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday_middleware"
5
+ require "rails/all"
6
+ require_relative "schoology_client/version"
7
+
8
+
9
+ module SchoologyClient
10
+
11
+ class << self
12
+ attr_accessor :configuration
13
+ end
14
+
15
+ autoload :Client, "schoology_client/client"
16
+ autoload :Configuration, "schoology_client/configuration"
17
+ autoload :Object, "schoology_client/object"
18
+ autoload :Resource, "schoology_client/resource"
19
+ autoload :Error, "schoology_client/error"
20
+ autoload :Railtie, "schoology_client/railtie"
21
+
22
+ # High-level categories of Schoology API calls
23
+ autoload :GroupResource, "schoology_client/resources/group"
24
+
25
+ # Classes used to return a nicer object wrapping the response data
26
+ autoload :Group, "schoology/objects/group"
27
+
28
+ def self.configuration
29
+ @configuration ||= SchoologyClient::Configuration.new
30
+ end
31
+
32
+ def self.configure
33
+ yield(configuration)
34
+ end
35
+
36
+ def initialize
37
+ @oauth_consumer_key = self.class.configuration.oauth_consumer_key
38
+ @oauth_consumer_secret = self.class.configuration.oauth_consumer_secret
39
+ @url = self.class.configuration.url
40
+ end
41
+ end
@@ -1,5 +0,0 @@
1
- SchoologyClient.configure |config|
2
- config.consumer_key = ENV['SCHOOLOGY_CONSUMER_KEY']
3
- config.consumer_secret = ENV['SCHOOLOGY_CONSUMER_SECRET']
4
- config.url = ENV['SCHOOLOGY_URL']
5
- end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ SchoologyClient.configure do |config|
4
+
5
+ # Schoology OAuth consumer key and secret can be found at https://app.schoology.com/api
6
+ config.oauth_consumer_key = ENV['SCHOOLOGY_OAUTH_CONSUMER_KEY']
7
+ config.oauth_consumer_secret = ENV['SCHOOLOGY_OAUTH_CONSUMER_SECRET']
8
+
9
+ # This is the base URL for the Schoology API. It should be set to
10
+ # to something like 'https://api.schoology.com/v1'
11
+ config.url = ENV['SCHOOLOGY_API_URL']
12
+
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongmind-schoology-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Strongmind
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-05 00:00:00.000000000 Z
11
+ date: 2023-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.x
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.x
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 7.x
61
+ version: '7.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 7.x
68
+ version: '7.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry
70
+ name: railties
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '7.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '7.0'
83
83
  description:
84
84
  email:
85
85
  - qwertytalk@strongmind.com
@@ -96,15 +96,18 @@ files:
96
96
  - Gemfile.lock
97
97
  - README.md
98
98
  - Rakefile
99
- - lib/schoology-client.rb
100
- - lib/schoology-client/client.rb
101
- - lib/schoology-client/error.rb
102
- - lib/schoology-client/object.rb
103
- - lib/schoology-client/objects/group.rb
104
- - lib/schoology-client/resource.rb
105
- - lib/schoology-client/resources/group.rb
106
- - lib/schoology-client/version.rb
99
+ - lib/schoology_client.rb
100
+ - lib/schoology_client/client.rb
101
+ - lib/schoology_client/configuration.rb
102
+ - lib/schoology_client/error.rb
103
+ - lib/schoology_client/generators/schoology_api/install_generator.rb
104
+ - lib/schoology_client/object.rb
105
+ - lib/schoology_client/objects/group.rb
106
+ - lib/schoology_client/resource.rb
107
+ - lib/schoology_client/resources/group.rb
108
+ - lib/schoology_client/version.rb
107
109
  - lib/templates/rails/initializer/schoology-client.rb.tt
110
+ - lib/templates/schoology_client_initializer.rb
108
111
  - sig/schoology.rbs
109
112
  homepage: https://github.com/Strongmind/schoology-client
110
113
  licenses: []
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'faraday'
3
- require 'faraday_middleware'
4
- require 'oauth'
5
-
6
- module SchoologyClient
7
- class Client
8
- BASE_URL = "https://api.schoology.com/v1"
9
-
10
- attr_reader :oauth_token, :adapter
11
-
12
- def initialize(oauth_token:, adapter: Faraday.default_adapter, stubs: nil)
13
- @oauth_token = oauth_token
14
- @adapter = adapter
15
- #used for tests
16
- @stubs = stubs
17
- end
18
-
19
- def group
20
- GroupResource.new(self)
21
- end
22
-
23
- def connection
24
- consumer_key = "2c40b07185fbd031567affed01fcff630644fee80"
25
- consumer_secret = "fd5863739d9f50922aa4f1cb9f4a4908"
26
-
27
- # Set up the OAuth 1.0 consumer
28
- consumer = OAuth::Consumer.new(
29
- consumer_key,
30
- consumer_secret,
31
- site: BASE_URL,
32
- scheme: :header,
33
- signature_method: 'PLAINTEXT',
34
- realm: 'Schoology API'
35
- )
36
-
37
- # Set up the Faraday connection
38
- # Set up the Faraday connection
39
- connection = Faraday.new(BASE_URL) do |conn|
40
- conn.request :url_encoded
41
- conn.response :json
42
- conn.adapter Faraday.default_adapter
43
- end
44
- end
45
- end
46
- end
47
-
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'pry'
3
-
4
- module SchoologyClient
5
- class GroupResource < Resource
6
- def create(**attributes)
7
- GroupResource.new post_request("groups", body: attributes).body
8
- end
9
- end
10
- end
11
-
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "faraday"
4
- require "faraday_middleware"
5
- require "rails/all"
6
- require_relative "schoology-client/version"
7
-
8
- module SchoologyClient
9
- autoload :Client, "schoology-client/client"
10
- autoload :Object, "schoology-client/object"
11
- autoload :Resource, "schoology-client/resource"
12
- autoload :Error, "schoology-client/error"
13
-
14
- # High-level categories of Schoology API calls
15
- autoload :GroupResource, "schoology-client/resources/group"
16
-
17
- # Classes used to return a nicer object wrapping the response data
18
- autoload :Group, "schoology/objects/group"
19
-
20
- class Railtie < Rails::Railtie
21
- initializer 'schoology-client.insert_into_initializer' do
22
- config_path = Rails.root.join('config/initializers/schoology-client.rb')
23
- template_path = File.expand_path('../../templates/rails/initializer/schoology-client.rb.tt', __FILE__)
24
- File.write(config_path, ERB.new(File.read(template_path)).result)
25
- end
26
- end
27
- end