Class: EdoolsSdk::School
- Inherits:
-
EdoolsBase
- Object
- EdoolsBase
- EdoolsSdk::School
- Defined in:
- lib/edools_sdk/school.rb
Overview
School class
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#adroll_adv_id ⇒ Object
Returns the value of attribute adroll_adv_id.
-
#adroll_pix_id ⇒ Object
Returns the value of attribute adroll_pix_id.
-
#cnpj ⇒ Object
Returns the value of attribute cnpj.
-
#company_name ⇒ Object
Returns the value of attribute company_name.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#domains ⇒ Object
Returns the value of attribute domains.
-
#email ⇒ Object
Returns the value of attribute email.
-
#event ⇒ Object
Returns the value of attribute event.
-
#facebook ⇒ Object
Returns the value of attribute facebook.
-
#google_plus ⇒ Object
Returns the value of attribute google_plus.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instagram ⇒ Object
Returns the value of attribute instagram.
-
#linkedin ⇒ Object
Returns the value of attribute linkedin.
-
#logo ⇒ Object
Returns the value of attribute logo.
-
#meta_available_locales ⇒ Object
Returns the value of attribute meta_available_locales.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#pinterest ⇒ Object
Returns the value of attribute pinterest.
-
#rdstation_token ⇒ Object
Returns the value of attribute rdstation_token.
-
#samba_access_token ⇒ Object
Returns the value of attribute samba_access_token.
-
#samba_key ⇒ Object
Returns the value of attribute samba_key.
-
#samba_player_key ⇒ Object
Returns the value of attribute samba_player_key.
-
#samba_project_id ⇒ Object
Returns the value of attribute samba_project_id.
-
#seo_description ⇒ Object
Returns the value of attribute seo_description.
-
#seo_title ⇒ Object
Returns the value of attribute seo_title.
-
#site ⇒ Object
Returns the value of attribute site.
-
#subdomain ⇒ Object
Returns the value of attribute subdomain.
-
#terms_of_use ⇒ Object
Returns the value of attribute terms_of_use.
-
#twitter ⇒ Object
Returns the value of attribute twitter.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#youtube ⇒ Object
Returns the value of attribute youtube.
Class Method Summary collapse
-
.create(token, props) ⇒ Object
Create a School Just id and name are populated after create.
-
.create!(token, props) ⇒ Object
Create a School, if anything goes wrong an exception will be raised Just id and name are populated after create.
-
.parse_json(props) ⇒ Object
Parse json to School object.
-
.parse_json_created(props) ⇒ Object
Parse created json to School object.
-
.update_by_id(id, props) ⇒ Object
Update School by id.
-
.update_by_id!(id, props) ⇒ Object
Update School by id, if anything goes wrong an exception will be raised.
Instance Method Summary collapse
-
#initialize ⇒ School
constructor
A new instance of School.
Methods inherited from EdoolsBase
Constructor Details
#initialize ⇒ School
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
#address ⇒ Object
Returns the value of attribute address.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def address @address end |
#adroll_adv_id ⇒ Object
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_id ⇒ Object
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 |
#cnpj ⇒ Object
Returns the value of attribute cnpj.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def cnpj @cnpj end |
#company_name ⇒ Object
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_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def created_at @created_at end |
#credentials ⇒ Object
Returns the value of attribute credentials.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def credentials @credentials end |
#domains ⇒ Object
Returns the value of attribute domains.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def domains @domains end |
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def email @email end |
#event ⇒ Object
Returns the value of attribute event.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def event @event end |
#facebook ⇒ Object
Returns the value of attribute facebook.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def facebook @facebook end |
#google_plus ⇒ Object
Returns the value of attribute google_plus.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def google_plus @google_plus end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def id @id end |
#instagram ⇒ Object
Returns the value of attribute instagram.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def instagram @instagram end |
#linkedin ⇒ Object
Returns the value of attribute linkedin.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def linkedin @linkedin end |
#logo ⇒ Object
Returns the value of attribute logo.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def logo @logo end |
#meta_available_locales ⇒ Object
Returns the value of attribute meta_available_locales.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def @meta_available_locales end |
#metadata ⇒ Object
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def password @password end |
#phone ⇒ Object
Returns the value of attribute phone.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def phone @phone end |
#pinterest ⇒ Object
Returns the value of attribute pinterest.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def pinterest @pinterest end |
#rdstation_token ⇒ Object
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_token ⇒ Object
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_key ⇒ Object
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_key ⇒ Object
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_id ⇒ Object
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_description ⇒ Object
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_title ⇒ Object
Returns the value of attribute seo_title.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def seo_title @seo_title end |
#site ⇒ Object
Returns the value of attribute site.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def site @site end |
#subdomain ⇒ Object
Returns the value of attribute subdomain.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def subdomain @subdomain end |
#terms_of_use ⇒ Object
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 |
#twitter ⇒ Object
Returns the value of attribute twitter.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def twitter @twitter end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/edools_sdk/school.rb', line 4 def updated_at @updated_at end |
#youtube ⇒ Object
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.logo = props['logo'] school. = props['metadata'] school. = 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 |