Sha256: 133c79ca200cb83b00bac4a460c574ee610d7cfd775bf3306f983373c97665ed

Contents?: true

Size: 685 Bytes

Versions: 2

Compression:

Stored size: 685 Bytes

Contents

require 'messagebird_texter/response'

module MessagebirdTexter
  class Request < ActionTexter::Request
    attr_accessor :body

    attr_reader :response

    def initialize(body)
      @body     = body
      @endpoint = MessagebirdTexter.config.endpoint
      @path     = MessagebirdTexter.config.path
      @api_key  = MessagebirdTexter.config.product_token
    end

    def perform
      uri = URI.parse(@endpoint)
      Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
        @response = Response.new(http.post(@path, body, 'Authorization' => "AccessKey #{@api_key}", 'Content-Type' => 'application/json'))
      end
      response
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
messagebird-texter-0.1.1 lib/messagebird_texter/request.rb
messagebird-texter-0.1.0 lib/messagebird_texter/request.rb