Class: InterFAX::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/interfax/client.rb
Defined Under Namespace
Classes: BadRequestError, NotFoundError, ServerError, UnauthorizedError
Constant Summary
collapse
- DOMAIN =
"rest.interfax.net".freeze
- USER_AGENT =
"InterFAX Ruby #{InterFAX::VERSION}".freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/interfax/client.rb', line 18
def initialize(options = {})
self.username = options.fetch(:username) do
ENV['INTERFAX_USERNAME'] || raise(KeyError, "Missing required argument: username")
end
self.password = options.fetch(:password) do
ENV['INTERFAX_PASSWORD'] || raise(KeyError, "Missing required argument: password")
end
self.http = Net::HTTP.new(DOMAIN, Net::HTTP.https_default_port)
http.set_debug_output $stdout if options[:debug]
http.use_ssl = true
end
|
Instance Attribute Details
32
33
34
|
# File 'lib/interfax/client.rb', line 32
def account
@account ||= InterFAX::Account.new(self)
end
|
#documents ⇒ Object
48
49
50
|
# File 'lib/interfax/client.rb', line 48
def documents
@documents ||= InterFAX::Documents.new(self)
end
|
52
53
54
|
# File 'lib/interfax/client.rb', line 52
def files
@files ||= InterFAX::Files.new(self)
end
|
Returns the value of attribute http.
12
13
14
|
# File 'lib/interfax/client.rb', line 12
def http
@http
end
|
44
45
46
|
# File 'lib/interfax/client.rb', line 44
def inbound
@inbound ||= InterFAX::Inbound.new(self)
end
|
40
41
42
|
# File 'lib/interfax/client.rb', line 40
def outbound
@outbound ||= InterFAX::Outbound.new(self)
end
|
Returns the value of attribute password.
12
13
14
|
# File 'lib/interfax/client.rb', line 12
def password
@password
end
|
Returns the value of attribute username.
12
13
14
|
# File 'lib/interfax/client.rb', line 12
def username
@username
end
|
Instance Method Details
#delete(path) ⇒ Object
72
73
74
75
76
|
# File 'lib/interfax/client.rb', line 72
def delete path
uri = uri_for(path)
request = Net::HTTP::Delete.new(uri.request_uri)
transmit(request)
end
|
#deliver(params = {}) ⇒ Object
36
37
38
|
# File 'lib/interfax/client.rb', line 36
def deliver params = {}
outbound.deliver(params)
end
|
#get(path, params = {}, valid_keys = {}) ⇒ Object
56
57
58
59
60
|
# File 'lib/interfax/client.rb', line 56
def get path, params = {}, valid_keys = {}
uri = uri_for(path, params, valid_keys)
request = Net::HTTP::Get.new(uri.request_uri)
transmit(request)
end
|
#post(path, params = {}, valid_keys = {}, headers = {}, body = nil) ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/interfax/client.rb', line 62
def post path, params = {}, valid_keys = {}, = {}, body = nil
uri = uri_for(path, params, valid_keys)
request = Net::HTTP::Post.new(uri.request_uri)
.each do |key, value|
request[key] = value
end
request.body = body if body
transmit(request)
end
|