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.

Parameters:

  • className (String)

    the name of the Parse collection.

  • body (Hash) (defaults to: {})

    the body of the request.

  • opts (Hash)

    additional options to pass to the Client request.

  • headers (Hash)

    additional HTTP headers to send with the request.

Returns:


63
64
65
66
67
# File 'lib/parse/api/objects.rb', line 63

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.

Parameters:

  • className (String)

    the name of the Parse collection.

  • id (String)

    The objectId of the record in the collection.

  • opts (Hash)

    additional options to pass to the Client request.

  • headers (Hash)

    additional HTTP headers to send with the request.

Returns:


75
76
77
78
79
# File 'lib/parse/api/objects.rb', line 75

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.

Parameters:

  • className (String)

    the name of the Parse collection.

  • id (String)

    The objectId of the record in the collection.

  • opts (Hash)

    additional options to pass to the Client request.

  • headers (Hash)

    additional HTTP headers to send with the request.

Returns:


87
88
89
90
91
# File 'lib/parse/api/objects.rb', line 87

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.

Parameters:

  • className (String)

    the name of the Parse collection.

  • query (Hash) (defaults to: {})

    The set of query constraints.

  • opts (Hash)

    additional options to pass to the Client request.

  • headers (Hash)

    additional HTTP headers to send with the request.

Returns:

See Also:


100
101
102
103
104
# File 'lib/parse/api/objects.rb', line 100

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.

Parameters:

  • className (String)

    the name of the Parse collection.

  • id (String)

    The objectId of the record in the collection.

  • body (Hash) (defaults to: {})

    The key value pairs to update.

  • opts (Hash)

    additional options to pass to the Client request.

  • headers (Hash)

    additional HTTP headers to send with the request.

Returns:


113
114
115
116
117
# File 'lib/parse/api/objects.rb', line 113

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.

Parameters:

  • className (String)

    the name of the Parse collection.

  • id (String) (defaults to: nil)

    optional objectId to add at the end of the path.

Returns:

  • (String)

    the API uri path


53
54
55
# File 'lib/parse/api/objects.rb', line 53

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