class Ubiquity::Envoi::API::Client
Attributes
http_client[RW]
logger[RW]
request[RW]
response[RW]
Public Class Methods
new(args = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 14 def initialize(args = { }) @http_client = HTTPClient.new(args) @logger = http_client.logger end
Public Instance Methods
content(args = { }, options = { })
click to toggle source
############################################################################################################## # @!group API
Endpoints
# File lib/ubiquity/envoi/api/client.rb, line 73 def content(args = { }, options = { }) http :get, 'content' end
content_create(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 77 def content_create(args = { }, options = { }) end
content_details(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 81 def content_details(args = { }, options = { }) http :get, "content/#{args[:id]}" end
content_field_details(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 85 def content_field_details(args = { }, options = { }) http :get, "content-field/#{args[:id]}" end
content_fieldset_details(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 89 def content_fieldset_details(args = { }, options = { }) http :get, "content-fieldset/#{args[:id]}" end
content_fieldsets(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 97 def content_fieldsets(args = { }, options = { }) http :get, 'content-fieldset' end
content_type_details(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 93 def content_type_details(args = { }, options = { }) http :get, "content-type/#{args[:id]}" end
content_types(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 101 def content_types(args = { }, options = { }) http :get, 'content-type' end
Also aliased as: content_types_get
file_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 106 def file_get(args = { }, options = { }) id = args[:id] http(:get, "file/#{id}") end
http(method, *args)
click to toggle source
Exposes HTTP Methods @example http(:get, '/')
# File lib/ubiquity/envoi/api/client.rb, line 63 def http(method, *args) @request = nil @response = http_client.send(method, *args) @request = http_client.request @response end
media_file_add_file(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 134 def media_file_add_file(args = { }, options = { }) process_request_using_class(Requests::MediaFileAddFile, args, options) end
Also aliased as: media_file_file_add
media_file_create(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 112 def media_file_create(args = { }, options = { }) # _request = Requests::BaseRequest.new( # args, # { # :http_path => 'media-files/media-file', # :http_method => :post, # :parameters => [ # { :name => :name, :required => true }, # { :name => :description }, # { :name => :file }, # { :name => :metadata }, # # { :name => 'file[path]', :aliases => [ :path ], :required => true }, # # { :name => 'file[mime]', :aliases => [ :mime, :mime_type ], :required => true }, # # { :name => 'file[size]', :aliases => [ :size ], :required => true }, # # { :name => 'file[width]', :aliases => [ :width ] } # ] # }.merge(options) # ) # process_request(_request, options) process_request_using_class(Requests::MediaFileCreate, args, options) end
media_file_delete(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 139 def media_file_delete(args = { }, options = { }) id = args[:id] http(:delete, "media-files/media-file/#{id}") end
media_file_files_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 151 def media_file_files_get(args = { }, options = { }) id = args[:id] || args[:media_file_id] http(:get, "media-files/media-file/#{id}/files") end
media_file_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 145 def media_file_get(args = { }, options = { }) id = args[:id] || args[:media_file_id] http(:get, "media-files/media-file/#{id}") end
media_file_secured_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 157 def media_file_secured_get(args = { }, options = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'media-files/media-file/#{path_arguments[:media_file_id]}/secure', :http_method => :post, # :body => args, :parameters => [ { :name => :media_file_id, :aliases => [ :id ], :send_in => :path }, { :name => :email, :send_in => :body }, ] } ) process_request(_request, options) end
media_file_transcode(args = { }, options = { })
click to toggle source
Transcode a Media File
@param [Hash] args @option args [String] :media_file_id @option args [String] :transcoder_id @option args [Hash] :transcoder_args @see envoi.io/api/documentation/media-files/media-files-transcode
# File lib/ubiquity/envoi/api/client.rb, line 181 def media_file_transcode(args = { }, options = { }) media_file_id = args[:media_file_id] transcoder_id = args[:transcoder_id] transcoder_args = args[:transcoder_args] || {} http(:post, "media-files/media-file/#{media_file_id}/action/transcode/#{transcoder_id}", transcoder_args) end
media_file_transcode_parameters_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 189 def media_file_transcode_parameters_get(args = { }, options = { }) media_file_id = args[:media_file_id] transcoder_id = args[:transcoder_id] http(:get, "media-files/media-file/#{media_file_id}/action/transcode/#{transcoder_id}") end
media_file_transcoders_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 196 def media_file_transcoders_get(args = { }, options = { }) media_file_id = args[:media_file_id] || args[:id] http(:get, "media-files/media-file/#{media_file_id}/action/transcode") end
media_file_update(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 202 def media_file_update(args = { }, options = { }) process_request_using_class(Requests::MediaFileUpdate, args, options) end
media_files_detailed_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 222 def media_files_detailed_get(args = { }, options = { }) # http(:get, 'media-files/media-file-detailed?_perPage=200') _request = Requests::BaseRequest.new( args, { :http_path => 'media-files/media-file-detailed', :parameters => [ { :name => :_perPage, :aliases => [ :perPage ], :default_value => '200' }, { :name => :_page, :alises => [ :page ], :default_value => '1' } ] } ) process_request(_request, options) end
media_files_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 206 def media_files_get(args = { }, options = { }) # http(:get, 'media-files/media-file?_perPage=200') _request = Requests::BaseRequest.new( args, { :http_path => 'media-files/media-file', :parameters => [ { :name => :_perPage, :default_value => '200' }, { :name => :_page, :default_value => '1' } ] } ) process_request(_request, options) end
paginator()
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 51 def paginator @paginator ||= Paginator.new(self, { :logger => logger }) if @response end
process_request(request, options = nil)
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 19 def process_request(request, options = nil) @paginator = nil @response = nil @request = request logger.warn { "Request is Missing Required Arguments: #{request.missing_required_arguments.inspect}" } unless request.missing_required_arguments.empty? if ([:all, 'all'].include?(request.arguments[:_page])) request.arguments[:_page] = 1 include_remaining_pages = true else include_remaining_pages = false end request.client = self unless request.client options ||= request.options return (options.fetch(:return_request, true) ? request : nil) unless options.fetch(:execute_request, true) #@response = http_client.call_method(request.http_method, { :path => request.path, :query => request.query, :body => request.body }, options) @response = request.execute if request.respond_to?(:success?) && !request.success? raise "Request failed. #{request.response.code} #{response.body}" end if include_remaining_pages return paginator.include_remaining_pages end @response end
process_request_using_class(request_class, args, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 55 def process_request_using_class(request_class, args, options = { }) @response = nil @request = request_class.new(args, options.merge(:client => self)) process_request(@request, options) end
project_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 238 def project_get(args = { }, options = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'production/project/#{path_arguments[:project_id]}', :parameters => [ { :name => :project_id, :aliases => [ :id ], :send_in => :path } ] } ) process_request(_request, options) end
projects_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 252 def projects_get(args = { }, options = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'production/project', :parameters => [ ] } ) process_request(_request, options) end
storages_get(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 266 def storages_get(args = { }, options = { }) http(:get, 'media-files/storage') end
user_create(args = { }, options = { })
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 270 def user_create(args = { }, options = { }) end
who()
click to toggle source
# File lib/ubiquity/envoi/api/client.rb, line 274 def who http :get, 'who' end