Class: Edools::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/edools.rb

Constant Summary collapse

BASE_URI =
"https://core.myedools.info/api".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
20
21
22
# File 'lib/edools.rb', line 15

def initialize(config = {})
  @access_token  = config[:access_token]
  @raise_errors  = config[:raise_errors] || false
  @retries       = config[:retries] || 0
  @read_timeout  = config[:read_timeout] || 10
  @write_timeout = config[:write_timeout] || 10
  @connection    = Excon.new(BASE_URI, persistent: config[:persistent] || false)
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



13
14
15
# File 'lib/edools.rb', line 13

def access_token
  @access_token
end

Instance Method Details

#close_connectionObject



29
30
31
# File 'lib/edools.rb', line 29

def close_connection
  @connection.reset
end

#coursesObject

list courses



49
50
51
# File 'lib/edools.rb', line 49

def courses
  run(:get,"/courses", [200])
end

#create_and_invitation_studant(params = {}) ⇒ Object

create studants and invitation



89
90
91
# File 'lib/edools.rb', line 89

def create_and_invitation_studant(params = {})
  run(:post, "/invitations", [201,422], JSON.dump(params))
end

#create_course(params = {}) ⇒ Object

create course



57
58
59
# File 'lib/edools.rb', line 57

def create_course(params = {})
  run(:post, "/courses", [201,422], JSON.dump(params))
end

#create_product(school_id, params = {}) ⇒ Object

create products



78
79
80
# File 'lib/edools.rb', line 78

def create_product(school_id, params = {})
  run(:post, "/schools/#{school_id}/school_products", [201,422], JSON.dump(params))
end

#create_school(params = {}) ⇒ Object

create school



39
40
41
# File 'lib/edools.rb', line 39

def create_school(params = {})
  run(:post, "/schools/wizard", [201,422], JSON.dump(params))
end

#create_studant(params = {}) ⇒ Object

create studants



98
99
100
# File 'lib/edools.rb', line 98

def create_studant(params = {})
  run(:post, "/studants/", [201,422], JSON.dump(params))
end

#destroy_course(id) ⇒ Object

destroy course



67
68
69
# File 'lib/edools.rb', line 67

def destroy_course(id)
  run(:put, "/courses/#{id}", [204,404])
end

#destroy_studant(id) ⇒ Object

destroy studant



109
110
111
# File 'lib/edools.rb', line 109

def destroy_studant(id)
  run(:delete, "/studants/#{id}", [204,404])
end

#inspectObject



24
25
26
27
# File 'lib/edools.rb', line 24

def inspect
  vars = instance_variables.map { |v| "#{v}=#{instance_variable_get(v).inspect}" }.join(', ')
  "<#{self.class}: #{vars}>"
end

#productsObject

TODO error not rerturn products list products



73
74
75
# File 'lib/edools.rb', line 73

def products
  run(:get,"/school_products", [200])
end

#show_course(id) ⇒ Object

show course



53
54
55
# File 'lib/edools.rb', line 53

def show_course(id)
  run(:get, "/courses/#{id}", [200])
end

#show_school(id) ⇒ Object

show school



35
36
37
# File 'lib/edools.rb', line 35

def show_school(id)
  run(:get, "/schools/#{id}", [200])
end

#show_studant(id) ⇒ Object

show studant



93
94
95
# File 'lib/edools.rb', line 93

def show_studant(id)
  run(:get, "/studants/#{id}", [200,404])
end

#studantsObject

studants



84
85
86
# File 'lib/edools.rb', line 84

def studants
  run(:get,"/studants", [200])
end

#update_course(id, params = {}) ⇒ Object

update course



62
63
64
# File 'lib/edools.rb', line 62

def update_course(id, params = {})
  run(:put, "/courses/#{id}", [200,422], JSON.dump(params))
end

#update_school(id, params = {}) ⇒ Object

update school



43
44
45
# File 'lib/edools.rb', line 43

def update_school(id, params = {})
  run(:put, "/schools/#{id}", [200,422], JSON.dump(params))
end

#update_studant(id, params = {}) ⇒ Object

update studants



104
105
106
# File 'lib/edools.rb', line 104

def update_studant(id, params = {})
  run(:put, "/studants/#{id}", [200,422], JSON.dump(params))
end