class Yunpiansms::HttpBase

Attributes

host[RW]
secret_key[RW]
url[RW]

Public Class Methods

new(host="", connection_adapter = :net_http, headers={}, debug_flg=false) click to toggle source
# File lib/yunpiansms/http_base.rb, line 8
def initialize(host="", connection_adapter = :net_http, headers={}, debug_flg=false)
  @host = host
  @connection_adapter = connection_adapter
  @headers = headers
end

Public Instance Methods

conn() click to toggle source
# File lib/yunpiansms/http_base.rb, line 17
def conn
  Faraday.new(:url => @host, :headers => @headers) do |faraday|
    faraday.request  :url_encoded
    faraday.response :logger, @logger, :bodies => true
    faraday.options.timeout = 5           # open/read timeout in seconds
    faraday.options.open_timeout = 2      # connection open timeout in seconds
    faraday.adapter  @connection_adapter 
  end
end
get(url, params={}) click to toggle source
# File lib/yunpiansms/http_base.rb, line 15
def get(url, params={}); conn.get url, params end
post(url, body={}) click to toggle source
# File lib/yunpiansms/http_base.rb, line 14
def post(url, body={});  conn.post url, body end