Class: StudyplusForSchoolSync::Client
- Inherits:
-
Object
- Object
- StudyplusForSchoolSync::Client
- Includes:
- Endpoint
- Defined in:
- lib/studyplus_for_school_sync/client.rb
Overview
Sync API Http Client
Constant Summary
Constants included from Endpoint
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#delete(path:) ⇒ Hash
DELETE Http Request.
-
#get(path:, params: nil) ⇒ Hash
GET Http Request.
-
#initialize(base_url:, access_token: nil) ⇒ Client
constructor
A new instance of Client.
-
#patch(path:, params: nil) ⇒ Hash
PATCH Http Request.
-
#post(path:, params: nil) ⇒ Hash
POST Http Request.
-
#put(path:, params: nil) ⇒ Hash
PUT Http Request.
Methods included from Endpoint::Student
#attach_student_tag, #create_passcode, #create_student_transfer, #create_study_record, #detach_student_tag, #inactivate_passcode, #student_tags, #student_transfer
Methods included from Endpoint::Partner
#create_partner, #create_student, #create_tag, #delete_tag, #tags, #update_tag
Methods included from Endpoint::LearningMaterial
#create_learning_material, #update_learning_material
Constructor Details
#initialize(base_url:, access_token: nil) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 23 24 |
# File 'lib/studyplus_for_school_sync/client.rb', line 16 def initialize(base_url:, access_token: nil) @base_url = base_url @access_token = access_token @conn = Faraday.new(headers: default_header) do |connection| connection.response :json connection.response :encoding connection.adapter Faraday.default_adapter end end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
12 13 14 |
# File 'lib/studyplus_for_school_sync/client.rb', line 12 def access_token @access_token end |
Instance Method Details
#delete(path:) ⇒ Hash
DELETE Http Request
69 70 71 |
# File 'lib/studyplus_for_school_sync/client.rb', line 69 def delete(path:) @conn.delete(build_url(path)) end |
#get(path:, params: nil) ⇒ Hash
GET Http Request
30 31 32 33 34 |
# File 'lib/studyplus_for_school_sync/client.rb', line 30 def get(path:, params: nil) @conn.get(build_url(path)) do |req| req.params = params if params end end |
#patch(path:, params: nil) ⇒ Hash
PATCH Http Request
60 61 62 63 64 |
# File 'lib/studyplus_for_school_sync/client.rb', line 60 def patch(path:, params: nil) @conn.patch(build_url(path)) do |req| req.body = params.to_json if params end end |
#post(path:, params: nil) ⇒ Hash
POST Http Request
40 41 42 43 44 |
# File 'lib/studyplus_for_school_sync/client.rb', line 40 def post(path:, params: nil) @conn.post(build_url(path)) do |req| req.body = params.to_json if params end end |
#put(path:, params: nil) ⇒ Hash
PUT Http Request
50 51 52 53 54 |
# File 'lib/studyplus_for_school_sync/client.rb', line 50 def put(path:, params: nil) @conn.put(build_url(path)) do |req| req.body = params.to_json if params end end |