Class: UplandMobileCommonsRest::Client
- Inherits:
-
Vertebrae::API
- Object
- Vertebrae::API
- UplandMobileCommonsRest::Client
- Defined in:
- lib/upland_mobile_commons_rest/client.rb
Instance Attribute Summary collapse
-
#company_key ⇒ Object
Returns the value of attribute company_key.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#campaigns ⇒ Object
Helper functions to let consumers do things like ‘client.campaigns.list`.
- #default_options ⇒ Object
-
#extract_data_from_params(params) ⇒ Object
:nodoc:.
- #groups ⇒ Object
-
#initialize(options = {}, &block) ⇒ Client
constructor
A new instance of Client.
- #profiles ⇒ Object
- #setup ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 7 def initialize( = {}, &block) self.username = [:username] self.password = [:password] self.company_key = [:company_key] super(, &block) end |
Instance Attribute Details
#company_key ⇒ Object
Returns the value of attribute company_key.
5 6 7 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 5 def company_key @company_key end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 5 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 5 def username @username end |
Instance Method Details
#campaigns ⇒ Object
Helper functions to let consumers do things like ‘client.campaigns.list`
52 53 54 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 52 def campaigns @_campaigns ||= UplandMobileCommonsRest::Campaigns.new(client: self) end |
#default_options ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 14 def { host: 'secure.mcommons.com', prefix: '/api', user_agent: 'ruby: UplandMobileCommonsRest', content_type: 'application/x-www-form-urlencoded', additional_headers: { 'Accept' => 'application/xml' } } end |
#extract_data_from_params(params) ⇒ Object
:nodoc:
46 47 48 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 46 def extract_data_from_params(params) # :nodoc: URI.encode_www_form(params) end |
#groups ⇒ Object
56 57 58 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 56 def groups @_groups ||= UplandMobileCommonsRest::Groups.new(client: self) end |
#profiles ⇒ Object
60 61 62 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 60 def profiles @_profiles ||= UplandMobileCommonsRest::Profiles.new(client: self) end |
#setup ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/upland_mobile_commons_rest/client.rb', line 26 def setup connection.stack do |builder| # Request middlewares, in the order they should run builder.use Faraday::Request::Multipart builder.use Faraday::Request::UrlEncoded if connection.configuration.authenticated? builder.use Faraday::Request::BasicAuthentication, connection.configuration.username, connection.configuration.password end # Response middlewares, in the *reverse* order they should run builder.use UplandMobileCommonsRest::TypedErrorMiddleware builder.use Faraday::Response::Logger if ENV['DEBUG'] builder.use FaradayMiddleware::ParseXml builder.use UplandMobileCommonsRest::HttpErrorMiddleware builder.adapter connection.configuration.adapter end end |