Class: Stannp::PostcardsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/stannp/resources/postcards.rb

Instance Method Summary collapse

Methods inherited from Resource

#get_request, #initialize, #post_request, #url_for

Constructor Details

This class inherits a constructor from Stannp::Resource

Instance Method Details

#cancel(id:) ⇒ Object



15
16
17
18
# File 'lib/stannp/resources/postcards.rb', line 15

def cancel(id:)
  url = url_for(path: 'postcards/cancel')
  post_request(url, body: { id: id }).body['success']
end

#create(attributes:) ⇒ Object



5
6
7
8
# File 'lib/stannp/resources/postcards.rb', line 5

def create(attributes:)
  url = url_for(path: 'postcards/create')
  Postcard.new(post_request(url, body: attributes).body['data'])
end

#get(id:) ⇒ Object



10
11
12
13
# File 'lib/stannp/resources/postcards.rb', line 10

def get(id:)
  url = url_for(path: "postcards/get/#{id}")
  Postcard.new(get_request(url).body['data'])
end