Sha256: 2dd653fb9990b64bf617346be312f3c818312b1f63c020fec93d04dd4ec712c6

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 Bytes

Contents

require 'bulutfon_sdk/rest/base_request'

module BulutfonSDK
  module REST
    class OutgoingFax < BaseRequest

      include BulutfonSDK::Util

      def initialize(*args)
        super(*args)
        @resource = 'outgoing-faxes'
      end

      def all( params = {} )
        prepare_request( 'get', @resource, params)
      end

      def get( id )
        prepare_request( 'get', "#{@resource}/#{id}")
      end

      def create(params)
        prepare_atachment(params)
        prepare_request( 'post', @resource, params)
      end

      private

      def prepare_atachment(params)
        file          = params[:attachment]
        basename      = File.basename file
        type          = file_content_type file
        content       = File.read(file)
        base_64_data  = Base64.strict_encode64(content)
        params[:attachment] = "data:#{type};name:#{basename};base64:#{base_64_data}"
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bulutfon_sdk-1.3.0 lib/bulutfon_sdk/rest/outgoing_fax.rb
bulutfon_sdk-1.2.1 lib/bulutfon_sdk/rest/outgoing_fax.rb
bulutfon_sdk-1.2.0 lib/bulutfon_sdk/rest/outgoing_fax.rb
bulutfon_sdk-1.1.3 lib/bulutfon_sdk/rest/outgoing_fax.rb
bulutfon_sdk-1.1.0 lib/bulutfon_sdk/rest/outgoing_fax.rb