Class: QRAPI::Client
- Inherits:
-
Object
- Object
- QRAPI::Client
- Defined in:
- lib/qrapi/client.rb
Instance Attribute Summary collapse
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
-
#data_center_id ⇒ Object
readonly
Returns the value of attribute data_center_id.
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #method_missing(name, *args, &block) ⇒ Object
- #resources ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/qrapi/client.rb', line 7 def initialize( = {}) @api_token = [:api_token] @data_center_id = [:data_center_id] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/qrapi/client.rb', line 33 def method_missing(name, *args, &block) if self.class.resources.keys.include?(name) resources[name] ||= self.class.resources[name].new(connection: connection) resources[name] else super end end |
Instance Attribute Details
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
5 6 7 |
# File 'lib/qrapi/client.rb', line 5 def api_token @api_token end |
#data_center_id ⇒ Object (readonly)
Returns the value of attribute data_center_id.
5 6 7 |
# File 'lib/qrapi/client.rb', line 5 def data_center_id @data_center_id end |
Class Method Details
.resources ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qrapi/client.rb', line 18 def self.resources { organization: OrganizationResource, divisions: DivisionResource, groups: GroupResource, users: UserResource, surveys: SurveyResource, response_exports: ResponseExportResource, response_imports: ResponseImportResource, library_messages: LibraryMessageResource, distributions: DistributionResource, mailing_lists: MailingListResource } end |
Instance Method Details
#connection ⇒ Object
12 13 14 15 16 |
# File 'lib/qrapi/client.rb', line 12 def connection Faraday.new() do |req| req.adapter :net_http end end |
#resources ⇒ Object
42 43 44 |
# File 'lib/qrapi/client.rb', line 42 def resources @resources ||= {} end |