Module: Parse::API::Objects

Included in:
Client
Defined in:
lib/parse/api/objects.rb

Overview

REST API methods for fetching CRUD operations on Parse objects.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#create_object(className, body = {}, headers: {}, **opts) ⇒ Parse::Response

Create an object in a collection.



60
61
62
63
64
# File 'lib/parse/api/objects.rb', line 60

def create_object(className, body = {}, headers: {}, **opts)
  response = request :post, uri_path(className), body: body, headers: headers, opts: opts
  response.parse_class = className if response.present?
  response
end

#delete_object(className, id, headers: {}, **opts) ⇒ Parse::Response

Delete an object in a collection.



72
73
74
75
76
# File 'lib/parse/api/objects.rb', line 72

def delete_object(className, id, headers: {}, **opts)
  response = request :delete, uri_path(className, id), headers: headers, opts: opts
  response.parse_class = className if response.present?
  response
end

#fetch_object(className, id, headers: {}, **opts) ⇒ Parse::Response

Fetch a specific object from a collection.



84
85
86
87
88
# File 'lib/parse/api/objects.rb', line 84

def fetch_object(className, id, headers: {}, **opts)
  response = request :get, uri_path(className, id), headers: headers, opts: opts
  response.parse_class = className if response.present?
  response
end

#find_objects(className, query = {}, headers: {}, **opts) ⇒ Parse::Response

Fetch a set of matching objects for a query.

See Also:



97
98
99
100
101
# File 'lib/parse/api/objects.rb', line 97

def find_objects(className, query = {}, headers: {}, **opts)
  response = request :get, uri_path(className), query: query, headers: headers, opts: opts
  response.parse_class = className if response.present?
  response
end

#update_object(className, id, body = {}, headers: {}, **opts) ⇒ Parse::Response

Update an object in a collection.



110
111
112
113
114
# File 'lib/parse/api/objects.rb', line 110

def update_object(className, id, body = {}, headers: {}, **opts)
  response = request :put, uri_path(className, id), body: body, headers: headers, opts: opts
  response.parse_class = className if response.present?
  response
end

#uri_path(className, id = nil) ⇒ String

Get the API path for this class.



50
51
52
# File 'lib/parse/api/objects.rb', line 50

def uri_path(className, id = nil)
  self.class.uri_path(className, id)
end