Module: Amiando
- Defined in:
- lib/amiando.rb,
lib/amiando/sync.rb,
lib/amiando/user.rb,
lib/amiando/event.rb,
lib/amiando/utils.rb,
lib/amiando/result.rb,
lib/amiando/api_key.rb,
lib/amiando/autorun.rb,
lib/amiando/boolean.rb,
lib/amiando/partner.rb,
lib/amiando/request.rb,
lib/amiando/version.rb,
lib/amiando/resource.rb,
lib/amiando/attributes.rb,
lib/amiando/ticket_shop.rb,
lib/amiando/ticket_type.rb,
lib/amiando/payment_type.rb,
lib/amiando/public/event.rb,
lib/amiando/ticket_category.rb
Defined Under Namespace
Modules: Attributes, Autorun, Public, Utils Classes: ApiKey, Boolean, Error, Event, Partner, PaymentType, Request, Resource, Result, Sync, TicketCategory, TicketShop, TicketType, User
Constant Summary collapse
- URL =
'https://www.amiando.com'- TEST_URL =
'https://test.amiando.com'- VERSION =
"0.4.5"
Class Attribute Summary collapse
-
.api_key ⇒ Object
Api key to be used at all times.
-
.autorun ⇒ Object
If set to true, will run the requests automatically when needed.
-
.base_url ⇒ String
The url for the environment.
-
.logger ⇒ Object
Logger instance.
-
.timeout ⇒ Object
Timeout value (in milliseconds).
-
.total_requests ⇒ Object
Used for statistics (time-bandits for example).
-
.total_time ⇒ Object
Used for statistics (time-bandits for example).
-
.verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
-
.development! ⇒ Object
Connect to the test server (default).
-
.production! ⇒ Object
Connect to the production server.
- .requests ⇒ Object
-
.run ⇒ Object
Runs all queued requests.
-
.with_key(key) ⇒ Object
Allows to switch temporarily the API key.
Class Attribute Details
.api_key ⇒ Object
Api key to be used at all times.
44 45 46 |
# File 'lib/amiando.rb', line 44 def api_key @api_key end |
.autorun ⇒ Object
If set to true, will run the requests automatically when needed.
52 53 54 |
# File 'lib/amiando.rb', line 52 def autorun @autorun end |
.base_url ⇒ String
Returns the url for the environment.
77 78 79 |
# File 'lib/amiando.rb', line 77 def base_url @base_url || (@production ? URL : TEST_URL) end |
.logger ⇒ Object
Logger instance. There’s no logger by default.
47 48 49 |
# File 'lib/amiando.rb', line 47 def logger @logger end |
.timeout ⇒ Object
Timeout value (in milliseconds). Default: 15 seconds.
58 59 60 |
# File 'lib/amiando.rb', line 58 def timeout @timeout end |
.total_requests ⇒ Object
Used for statistics (time-bandits for example)
61 62 63 |
# File 'lib/amiando.rb', line 61 def total_requests @total_requests end |
.total_time ⇒ Object
Used for statistics (time-bandits for example)
61 62 63 |
# File 'lib/amiando.rb', line 61 def total_time @total_time end |
.verbose ⇒ Object
Returns the value of attribute verbose.
49 50 51 |
# File 'lib/amiando.rb', line 49 def verbose @verbose end |
Class Method Details
.development! ⇒ Object
Connect to the test server (default)
72 73 74 |
# File 'lib/amiando.rb', line 72 def development! @production = false end |
.production! ⇒ Object
Connect to the production server
67 68 69 |
# File 'lib/amiando.rb', line 67 def production! @production = true end |
.requests ⇒ Object
81 82 83 |
# File 'lib/amiando.rb', line 81 def requests @requests ||= [] end |
.run ⇒ Object
Runs all queued requests
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/amiando.rb', line 86 def run exception = nil requests.each { |request| hydra.queue(request) } @total_requests += requests.size duration = Benchmark.realtime do begin hydra.run rescue Exception => exception end end @total_time += duration raise exception if exception ensure @requests = [] end |
.with_key(key) ⇒ Object
Allows to switch temporarily the API key
110 111 112 113 114 115 116 |
# File 'lib/amiando.rb', line 110 def with_key(key) old_key = Amiando.api_key Amiando.api_key = key yield ensure Amiando.api_key = old_key end |