Class: Schoolkeep::Client
- Inherits:
-
Object
- Object
- Schoolkeep::Client
- Defined in:
- lib/schoolkeep/client.rb
Defined Under Namespace
Classes: InvalidTemplateName
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #delete(name) ⇒ Object
- #get_fixtures ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
- #upload(name, path, engine) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
10 11 12 |
# File 'lib/schoolkeep/client.rb', line 10 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/schoolkeep/client.rb', line 6 def api_key @api_key end |
Instance Method Details
#delete(name) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/schoolkeep/client.rb', line 27 def delete(name) unless TEMPLATE_NAMES.include? name raise InvalidTemplateName.new("#{name} is an invalid template") end connection.delete "/v1/custom_templates.json", { id: name } end |
#get_fixtures ⇒ Object
36 37 38 |
# File 'lib/schoolkeep/client.rb', line 36 def get_fixtures connection.get "/v1/fixtures.yaml" end |
#upload(name, path, engine) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/schoolkeep/client.rb', line 14 def upload(name, path, engine) unless TEMPLATE_NAMES.include? name raise InvalidTemplateName.new("#{name} is an invalid template") end connection.post "/v1/custom_templates.json", { custom_template: { name: name, body: Faraday::UploadIO.new(path, 'text/plain; charset=utf-8'), engine: engine } } end |