Class: EdoolsSdk::School

Inherits:
EdoolsBase show all
Defined in:
lib/edools_sdk/school.rb

Overview

School class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from EdoolsBase

#to_h

Constructor Details

#initializeSchool

Returns a new instance of School.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/edools_sdk/school.rb', line 46

def initialize
  @id = nil
  @credentials = nil
  @name = nil
  @password = nil
  @subdomain = nil
  @domains = nil
  @rdstation_token = nil
  @adroll_adv_id = nil
  @adroll_pix_id = nil
  @email = nil
  @phone = nil
  @cnpj = nil
  @samba_key = nil
  @samba_player_key = nil
  @samba_access_token = nil
  @samba_project_id = nil
  @terms_of_use = nil
  @adroll_adv_id = nil
  @adroll_pix_id = nil
  @facebook = nil
  @twitter = nil
  @linkedin = nil
  @pinterest = nil
  @google_plus = nil
  @youtube = nil
  @instagram = nil
  @site = nil
  @address = nil
  @company_name = nil
  @seo_title = nil
  @seo_description = nil
  @logo = nil
  @metadata = nil
  @meta_available_locales = nil
  @event = nil
  @created_at = nil
  @updated_at = nil
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def address
  @address
end

#adroll_adv_idObject

Returns the value of attribute adroll_adv_id.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def adroll_adv_id
  @adroll_adv_id
end

#adroll_pix_idObject

Returns the value of attribute adroll_pix_id.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def adroll_pix_id
  @adroll_pix_id
end

#cnpjObject

Returns the value of attribute cnpj.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def cnpj
  @cnpj
end

#company_nameObject

Returns the value of attribute company_name.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def company_name
  @company_name
end

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def created_at
  @created_at
end

#credentialsObject

Returns the value of attribute credentials.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def credentials
  @credentials
end

#domainsObject

Returns the value of attribute domains.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def domains
  @domains
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def email
  @email
end

#eventObject

Returns the value of attribute event.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def event
  @event
end

#facebookObject

Returns the value of attribute facebook.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def facebook
  @facebook
end

#google_plusObject

Returns the value of attribute google_plus.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def google_plus
  @google_plus
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def id
  @id
end

#instagramObject

Returns the value of attribute instagram.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def instagram
  @instagram
end

#linkedinObject

Returns the value of attribute linkedin.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def linkedin
  @linkedin
end

#logoObject

Returns the value of attribute logo.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def 
  @logo
end

#meta_available_localesObject

Returns the value of attribute meta_available_locales.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def meta_available_locales
  @meta_available_locales
end

#metadataObject

Returns the value of attribute metadata.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def name
  @name
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def password
  @password
end

#phoneObject

Returns the value of attribute phone.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def phone
  @phone
end

#pinterestObject

Returns the value of attribute pinterest.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def pinterest
  @pinterest
end

#rdstation_tokenObject

Returns the value of attribute rdstation_token.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def rdstation_token
  @rdstation_token
end

#samba_access_tokenObject

Returns the value of attribute samba_access_token.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def samba_access_token
  @samba_access_token
end

#samba_keyObject

Returns the value of attribute samba_key.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def samba_key
  @samba_key
end

#samba_player_keyObject

Returns the value of attribute samba_player_key.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def samba_player_key
  @samba_player_key
end

#samba_project_idObject

Returns the value of attribute samba_project_id.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def samba_project_id
  @samba_project_id
end

#seo_descriptionObject

Returns the value of attribute seo_description.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def seo_description
  @seo_description
end

#seo_titleObject

Returns the value of attribute seo_title.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def seo_title
  @seo_title
end

#siteObject

Returns the value of attribute site.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def site
  @site
end

#subdomainObject

Returns the value of attribute subdomain.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def subdomain
  @subdomain
end

#terms_of_useObject

Returns the value of attribute terms_of_use.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def terms_of_use
  @terms_of_use
end

#twitterObject

Returns the value of attribute twitter.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def twitter
  @twitter
end

#updated_atObject

Returns the value of attribute updated_at.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def updated_at
  @updated_at
end

#youtubeObject

Returns the value of attribute youtube.



4
5
6
# File 'lib/edools_sdk/school.rb', line 4

def youtube
  @youtube
end

Class Method Details

.create(token, props) ⇒ Object

Create a School Just id and name are populated after create

Example:

>> School.create(token, "name" => "test")
=> #<EdoolsSdk::School:0x0000000234d350 @id=nil, @credentials=nil, @name="test", @password=nil, @subdomain=nil, @domains=nil, @rdstation_token=nil, @adroll_adv_id=nil, @adroll_pix_id=nil, @email=nil, @phone=nil, @cnpj=nil, @samba_key=nil, @samba_player_key=nil, @samba_access_token=nil, @samba_project_id=nil, @terms_of_use=nil, @facebook=nil, @twitter=nil, @linkedin=nil, @pinterest=nil, @google_plus=nil, @youtube=nil, @instagram=nil, @site=nil, @address=nil, @company_name=nil, @seo_title=nil, @seo_description=nil, @logo=nil, @metadata=nil, @meta_available_locales=nil, @event=nil, @created_at=nil, @updated_at=nil>


169
170
171
172
173
174
175
176
177
178
179
# File 'lib/edools_sdk/school.rb', line 169

def self.create(token, props)
  response = HTTP
    .headers('Authorization' => "Token token=\"#{token}\"")
    .post(SCHOOL_URL_CREATE, :json => props)

  return response if response.status != 201

  body = response.parse(:json)

  School.parse_json_created(body)
end

.create!(token, props) ⇒ Object

Create a School, if anything goes wrong an exception will be raised Just id and name are populated after create

Example:

>> School.create!(token, "name" => "test")
=> #<EdoolsSdk::School:0x0000000234d350 @id=nil, @credentials=nil, @name="test", @password=nil, @subdomain=nil, @domains=nil, @rdstation_token=nil, @adroll_adv_id=nil, @adroll_pix_id=nil, @email=nil, @phone=nil, @cnpj=nil, @samba_key=nil, @samba_player_key=nil, @samba_access_token=nil, @samba_project_id=nil, @terms_of_use=nil, @facebook=nil, @twitter=nil, @linkedin=nil, @pinterest=nil, @google_plus=nil, @youtube=nil, @instagram=nil, @site=nil, @address=nil, @company_name=nil, @seo_title=nil, @seo_description=nil, @logo=nil, @metadata=nil, @meta_available_locales=nil, @event=nil, @created_at=nil, @updated_at=nil>


151
152
153
154
155
156
157
158
159
160
161
# File 'lib/edools_sdk/school.rb', line 151

def self.create!(token, props)
  response = HTTP
    .headers('Authorization' => "Token token=\"#{token}\"")
    .post(SCHOOL_URL_CREATE, :json => props)

  raise "invalid status code #{response.status}" if response.status != 201

  body = response.parse(:json)

  School.parse_json_created(body)
end

.parse_json(props) ⇒ Object

Parse json to School object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/edools_sdk/school.rb', line 87

def self.parse_json(props)
  school = School.new

  school.id = props['id']
  school.name = props['name']
  school.password = props['password']
  school.subdomain = props['subdomain']
  school.domains = props['domains']
  school.rdstation_token = props['rdstation_token']
  school.adroll_adv_id = props['adroll_adv_id']
  school.adroll_pix_id = props['adroll_pix_id']
  school.email = props['email']
  school.phone = props['phone']
  school.cnpj = props['cnpj']
  school.samba_key = props['samba_key']
  school.samba_player_key = props['samba_player_key']
  school.samba_access_token = props['samba_access_token']
  school.samba_project_id = props['samba_project_id']
  school.terms_of_use = props['terms_of_use']
  school.adroll_adv_id = props['adroll_adv_id']
  school.adroll_pix_id = props['adroll_pix_id']
  school.facebook = props['facebook']
  school.twitter = props['twitter']
  school.linkedin = props['linkedin']
  school.pinterest = props['pinterest']
  school.google_plus = props['google_plus']
  school.youtube = props['youtube']
  school.instagram = props['instagram']
  school.site = props['site']
  school.address = props['address']
  school.company_name = props['company_name']
  school.seo_title = props['seo_title']
  school.seo_description = props['seo_description']
  school. = props['logo']
  school. = props['metadata']
  school.meta_available_locales = props['meta_available_locales']
  school.event = props['event']

  unless props['created_at'].nil?
    school.created_at = Date.parse(props['created_at'])
  end
  unless props['updated_at'].nil?
    school.updated_at = Date.parse(props['updated_at'])
  end

  school
end

.parse_json_created(props) ⇒ Object

Parse created json to School object



136
137
138
139
140
141
142
143
# File 'lib/edools_sdk/school.rb', line 136

def self.parse_json_created(props)
  school = School.new

  school.id = props['school']['id']
  school.credentials = props['admin']['credentials']

  school
end

.update_by_id(id, props) ⇒ Object

Update School by id

Example:

>> School.update_by_id(22, "name" => "test")
=> #<EdoolsSdk::School:0x0000000234d350 @id=nil, @credentials=nil, @name="test", @password=nil, @subdomain=nil, @domains=nil, @rdstation_token=nil, @adroll_adv_id=nil, @adroll_pix_id=nil, @email=nil, @phone=nil, @cnpj=nil, @samba_key=nil, @samba_player_key=nil, @samba_access_token=nil, @samba_project_id=nil, @terms_of_use=nil, @facebook=nil, @twitter=nil, @linkedin=nil, @pinterest=nil, @google_plus=nil, @youtube=nil, @instagram=nil, @site=nil, @address=nil, @company_name=nil, @seo_title=nil, @seo_description=nil, @logo=nil, @metadata=nil, @meta_available_locales=nil, @event=nil, @created_at=nil, @updated_at=nil>


186
187
188
189
190
191
192
193
194
# File 'lib/edools_sdk/school.rb', line 186

def self.update_by_id(id, props)
  response = HTTP
    .headers('Authorization' => "Token token=\"#{ENV['edools_token']}\"")
    .put("#{SCHOOL_URL_UPDATE}#{id}", :json => props)

  return response if response.status != 204
  
  School.parse_json(props)
end

.update_by_id!(id, props) ⇒ Object

Update School by id, if anything goes wrong an exception will be raised

Example:

>> School.update_by_id!(22, "name" => "test")
=> #<EdoolsSdk::School:0x0000000234d350 @id=nil, @credentials=nil, @name="test", @password=nil, @subdomain=nil, @domains=nil, @rdstation_token=nil, @adroll_adv_id=nil, @adroll_pix_id=nil, @email=nil, @phone=nil, @cnpj=nil, @samba_key=nil, @samba_player_key=nil, @samba_access_token=nil, @samba_project_id=nil, @terms_of_use=nil, @facebook=nil, @twitter=nil, @linkedin=nil, @pinterest=nil, @google_plus=nil, @youtube=nil, @instagram=nil, @site=nil, @address=nil, @company_name=nil, @seo_title=nil, @seo_description=nil, @logo=nil, @metadata=nil, @meta_available_locales=nil, @event=nil, @created_at=nil, @updated_at=nil>


201
202
203
204
205
206
207
208
209
# File 'lib/edools_sdk/school.rb', line 201

def self.update_by_id!(id, props)
  response = HTTP
    .headers('Authorization' => "Token token=\"#{ENV['edools_token']}\"")
    .put("#{SCHOOL_URL_UPDATE}#{id}", :json => props)

  raise "invalid status code #{response.status}" if response.status != 204

  School.parse_json(props)
end