Last active
August 29, 2015 14:22
-
-
Save damienh/d41e87e8310a4ab5b029 to your computer and use it in GitHub Desktop.
EB v3 Calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_event | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.post("https://www.eventbriteapi.com/v3/events/", | |
:body => event_params, | |
:headers => {'Content-Type' => 'application/json', 'Authorization' => AUTH } ) | |
end | |
@returned_event = JSON.parse(response.body) | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end | |
def update_event | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.post("https://www.eventbriteapi.com/v3/events/#{event.eventbrite_id}/", | |
:body => event_params, | |
:headers => {'Content-Type' => 'application/json', 'Authorization' => AUTH } ) | |
end | |
@returned_event = JSON.parse(response.body) | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end | |
def get_event | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.get("https://www.eventbriteapi.com/v3/events/#{eventbrite_id}", | |
:headers => {'Authorization' => AUTH } ) | |
end | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end | |
def publish_event | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.post("https://www.eventbriteapi.com/v3/events/#{event.eventbrite_id}/publish/", | |
:headers => {'Authorization' => AUTH } ) | |
end | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end | |
def create_primary_ticket(ticket) | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.post("https://www.eventbriteapi.com/v3/events/""#{event.eventbrite_id}""/ticket_classes/", | |
:body => primary_ticket_params(ticket), | |
:headers => {'Content-Type' => 'application/json', 'Authorization' => AUTH } ) | |
end | |
@returned_ticket_class = JSON.parse(response.body) | |
return @returned_ticket_class['id'] | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end | |
def create_secondary_ticket(ticket) | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.post("https://www.eventbriteapi.com/v3/events/""#{event.eventbrite_id}""/ticket_classes/", | |
:body => secondary_ticket_params(ticket), | |
:headers => {'Content-Type' => 'application/json', 'Authorization' => AUTH } ) | |
end | |
returned_ticket_id = JSON.parse(response.body) | |
return returned_ticket_id['id'] | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end | |
def update_ticket(ticket) | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.post("https://www.eventbriteapi.com/v3/events/16981505139/ticket_classes/""#{ticket.eventbrite_id}/", | |
:body => updated_ticket_params(ticket), | |
:headers => {'Content-Type' => 'application/json', 'Authorization' => AUTH } ) | |
end | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end | |
def create_venue | |
begin | |
response = Http::Exceptions.wrap_and_check do | |
HTTParty.post("https://www.eventbriteapi.com/v3/venues/", | |
:body => venue_params, | |
:headers => {'Content-Type' => 'application/json', 'Authorization' => AUTH } ) | |
end | |
venue = JSON.parse(response.body) | |
return venue["id"] | |
rescue Http::Exceptions::HttpException => e | |
raise e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment