Class: BaseAdapter
- Inherits:
-
Object
show all
- Defined in:
- lib/adapters/base_adapter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config = {}) ⇒ BaseAdapter
Returns a new instance of BaseAdapter.
26
27
28
29
|
# File 'lib/adapters/base_adapter.rb', line 26
def initialize(config = {})
@login = config["login"]
@password = config["password"]
end
|
Instance Attribute Details
6
7
8
|
# File 'lib/adapters/base_adapter.rb', line 6
def
@headers ||=
end
|
Instance Method Details
18
19
20
21
22
23
24
|
# File 'lib/adapters/base_adapter.rb', line 18
def (request)
.each do ||
request.add_field([0], [1])
end
request
end
|
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/adapters/base_adapter.rb', line 31
def add_tags(message, tags)
@message = message.strip
unless tags.empty?
tags.each do |tag|
@message << " ##{tag.strip}"
end
end
@message
end
|
10
11
12
13
14
15
16
|
# File 'lib/adapters/base_adapter.rb', line 10
def
= []
<< ["User-Agent", Twilip::Client::USER_AGENT]
<< ["Accept", "application/json"]
<< ["Pragma", "no-cache"]
end
|
#process_deliver(api_url, *form_data) ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/adapters/base_adapter.rb', line 42
def process_deliver(api_url, *form_data)
url = URI.parse(api_url)
request = Net::HTTP::Post.new(url.path)
request.basic_auth @login, @password
request.set_form_data(*form_data)
response = Net::HTTP.new(url.host, url.port).start {|http| http.request((request)) }
JSON.parse(response.body)
end
|