Class: EShipper::Request
- Inherits:
-
Object
show all
- Defined in:
- lib/eshipper/requests/request.rb
Instance Method Summary
collapse
Instance Method Details
#build(&block) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/eshipper/requests/request.rb', line 7
def build(&block)
throw "Missing EShipper::Client.instance.username" unless client.username
throw "Missing EShipper::Client.instance.password" unless client.password
Nokogiri::XML::Builder.new do |xml|
xml.EShipper(
version: "3.1.0",
xmlns: "http://www.eshipper.net/XMLSchema",
username: client.username,
password: client.password
) do
yield(xml)
end
end
end
|
#client ⇒ Object
3
4
5
|
# File 'lib/eshipper/requests/request.rb', line 3
def client
EShipper::Client.instance
end
|
#send_now ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/eshipper/requests/request.rb', line 23
def send_now
uri = URI(EShipper::Client.instance.url)
http_request = Net::HTTP::Post.new(uri.path)
http_request.body = request_body
http_session = Net::HTTP.new(uri.host, uri.port)
http_session.use_ssl = true
http_session.ssl_version = :TLSv1
http_session.read_timeout = 3000
http_response = http_session.start do |http|
http.request(http_request)
end
http_response.body
end
|