Class: EventbriteSDK::Media

Inherits:
Resource show all
Defined in:
lib/eventbrite_sdk/media.rb

Overview

This module implements media upload to Eventbrite based on: docs.evbhome.com/apidocs/reference/uploads/?highlight=logo

Constant Summary collapse

VALID_TYPES =
{
  event_logo: 'image-event-logo',
  organizer_logo: 'image-organizer-logo',
  user_photo: 'image-user-photo',
  event_view_from_seat: 'image-event-view-from-seat'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

build, define_api_actions, #delete, #initialize, #inspect, #new?, #read_attribute_for_serialization, #refresh!, #save, #to_json

Methods included from Resource::Operations::Relationships

included

Methods included from Resource::Operations::Endpoint

included

Methods included from Resource::Operations::AttributeSchema

included

Constructor Details

This class inherits a constructor from EventbriteSDK::Resource

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/eventbrite_sdk/media.rb', line 7

def file
  @file
end

#image_typeObject (readonly)

Returns the value of attribute image_type.



7
8
9
# File 'lib/eventbrite_sdk/media.rb', line 7

def image_type
  @image_type
end

Instance Method Details

#upload!(image_type, file) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/eventbrite_sdk/media.rb', line 26

def upload!(image_type, file)
  # Media uploads through the API involve a multiple step process:

  # 1. Retrieve upload instructions + an upload token from the API
  instructions = get_instructions(image_type)

  # 2. Upload the file to the endpoint specified in the upload instructions
  eventbrite_upload(file, instructions)

  # 3. When the upload has finished, notify the API by re-sending the
  #    upload token from step 1
  notify(instructions['upload_token'])

  true
end