Class: Cubaru::V1::Postcard::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/cubaru/v1/postcard/resource.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ Resource

Returns a new instance of Resource.



6
7
8
# File 'lib/cubaru/v1/postcard/resource.rb', line 6

def initialize(resource)
  @resource = resource
end

Instance Method Details

#create(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cubaru/v1/postcard/resource.rb', line 18

def create(options = {})
  if options[:to] && !options[:to].is_a?(String)
    options[:to] = @resource.format_address_params(options[:to])
  end

  if options[:from] && !options[:from].is_a?(String)
    options[:from] = @resource.format_address_params(options[:from])
  end

  Cubaru.submit :post, postcard_url, options
end

#find(postcard_id) ⇒ Object



14
15
16
# File 'lib/cubaru/v1/postcard/resource.rb', line 14

def find(postcard_id)
  Cubaru.submit :get, postcard_url(postcard_id)
end

#list(options = {}) ⇒ Object



10
11
12
# File 'lib/cubaru/v1/postcard/resource.rb', line 10

def list(options={})
  Cubaru.submit(:get, postcard_url, options)["data"] || []
end