Class: BenchmarkEmail::Client
- Inherits:
-
Object
- Object
- BenchmarkEmail::Client
- Defined in:
- lib/benchmark_email.rb
Constant Summary collapse
- API_URL =
'https://clientapi.benchmarkemail.com'
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
- #get_contact_lists ⇒ Object
-
#initialize(access_token = nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(access_token = nil) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/benchmark_email.rb', line 13 def initialize(access_token = nil) @access_token = access_token || ENV['BENCHMARK_EMAIL_API_TOKEN'] raise EmptyTokenError if @access_token.nil? || @access_token.empty? end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
11 12 13 |
# File 'lib/benchmark_email.rb', line 11 def access_token @access_token end |
Instance Method Details
#get_contact_lists ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/benchmark_email.rb', line 18 def get_contact_lists url = URI("#{API_URL}/Contact/") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["AuthToken"] = @access_token request["Content-Type"] = "application/json" JSON.parse(https.request(request).body) end |