Class: Baidu::Push::API

Inherits:
Object
  • Object
show all
Defined in:
lib/baidu/push/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Returns a new instance of API.



8
9
10
11
12
13
14
15
# File 'lib/baidu/push/api.rb', line 8

def initialize(options = {})
  @connection = Faraday.new(url: default_domain) do |faraday|
    faraday.request :multipart
    faraday.request :url_encoded
    faraday.response :logger, options[:logger] if options[:logger]
    faraday.adapter Faraday.default_adapter
  end
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/baidu/push/api.rb', line 6

def connection
  @connection
end

Instance Method Details

#base_pathObject



17
18
19
# File 'lib/baidu/push/api.rb', line 17

def base_path
  '/rest/2.0/channel'
end

#default_domainObject



21
22
23
# File 'lib/baidu/push/api.rb', line 21

def default_domain
  'https://channel.api.duapp.com'
end