Class: PlateApi::Connector

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(public_key, secret_key, custom_server = nil) ⇒ Connector

Returns a new instance of Connector.



4
5
6
7
8
9
# File 'lib/plate_api/connector.rb', line 4

def initialize(public_key, secret_key, custom_server=nil)
  @custom_server = custom_server
  @public_key = public_key
  @secret_key = secret_key
  @handling_classes = {}
end

Class Method Details

.plate_object_classesObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/plate_api/connector.rb', line 35

def self.plate_object_classes
  {
    sites: PlateApi::PlateObject::Site,
    partners: PlateApi::PlateObject::Partner,
    companies: PlateApi::PlateObject::Company,
    themes: PlateApi::PlateObject::Theme,
    site_translations: PlateApi::PlateObject::SiteTranslation,
    posts: PlateApi::PlateObject::Post,
    sections: PlateApi::PlateObject::Section,
    rows: PlateApi::PlateObject::Row,
    columns: PlateApi::PlateObject::Column,
    elements: PlateApi::PlateObject::Element,
    content_objects: PlateApi::PlateObject::ContentObject,
    attachments: PlateApi::PlateObject::Attachment
  }
end

Instance Method Details

#delete(url = "", parameters = {}, response_type = :json) ⇒ Object



15
16
17
# File 'lib/plate_api/connector.rb', line 15

def delete(url="", parameters={}, response_type=:json)
  DeleteRequest.new(@public_key, @secret_key, url, parameters, @custom_server).execute(response_type)
end

#get(url = "", parameters = {}, response_type = :json) ⇒ Object



11
12
13
# File 'lib/plate_api/connector.rb', line 11

def get(url="", parameters={}, response_type=:json)
  GetRequest.new(@public_key, @secret_key, url, parameters, @custom_server).execute(response_type)
end

#handler(handled_class) ⇒ Object



31
32
33
# File 'lib/plate_api/connector.rb', line 31

def handler(handled_class)
  @handling_classes[handled_class] ||= ObjectHandler.new(handled_class, self)
end

#post(url = "", post_params = {}, response_type = :json) ⇒ Object



23
24
25
# File 'lib/plate_api/connector.rb', line 23

def post(url="", post_params={}, response_type=:json)
  PostRequest.new(@public_key, @secret_key, url, post_params, @custom_server).execute(response_type)
end

#post_multipart(url = "", post_params = {}, response_type = :json) ⇒ Object



27
28
29
# File 'lib/plate_api/connector.rb', line 27

def post_multipart(url="", post_params={}, response_type=:json)
  PostMultipartRequest.new(@public_key, @secret_key, url, post_params, @custom_server).execute(response_type)
end

#put(url = "", put_params = {}, response_type = :json) ⇒ Object



19
20
21
# File 'lib/plate_api/connector.rb', line 19

def put(url="", put_params={}, response_type=:json)
  PutRequest.new(@public_key, @secret_key, url, put_params, @custom_server).execute(response_type)
end