Class: Googlepay::EventTicketClass

Inherits:
Object
  • Object
show all
Defined in:
lib/googlepay/event_ticket_class.rb

Constant Summary collapse

EVENT_URL =
'https://www.googleapis.com/walletobjects/v1/eventTicketClass'

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ EventTicketClass

Returns a new instance of EventTicketClass.



6
7
8
# File 'lib/googlepay/event_ticket_class.rb', line 6

def initialize(parameters)
  @parameters = parameters
end

Instance Method Details

#createObject



10
11
12
13
14
15
16
# File 'lib/googlepay/event_ticket_class.rb', line 10

def create
  result = HTTParty.post("#{EVENT_URL}?access_token=#{Googlepay.token}",
                           :body => @parameters.to_json,
                           :headers => { 'Content-Type' => 'application/json' } )
  return result if result['error'].nil?
  update if result['error']['code'] == 409
end

#updateObject



18
19
20
21
22
# File 'lib/googlepay/event_ticket_class.rb', line 18

def update
  HTTParty.put("#{EVENT_URL}/#{@parameters[:id]}?access_token=#{Googlepay.token}",
               :body => @parameters.to_json,
               :headers => { 'Content-Type' => 'application/json' } )
end