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

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Api key to be used at all times.



44
45
46
# File 'lib/amiando.rb', line 44

def api_key
  @api_key
end

.autorunObject

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_urlString

Returns the url for the environment.

Returns:

  • (String)

    the url for the environment



77
78
79
# File 'lib/amiando.rb', line 77

def base_url
  @base_url || (@production ? URL : TEST_URL)
end

.loggerObject

Logger instance. There’s no logger by default.



47
48
49
# File 'lib/amiando.rb', line 47

def logger
  @logger
end

.timeoutObject

Timeout value (in milliseconds). Default: 15 seconds.



58
59
60
# File 'lib/amiando.rb', line 58

def timeout
  @timeout
end

.total_requestsObject

Used for statistics (time-bandits for example)



61
62
63
# File 'lib/amiando.rb', line 61

def total_requests
  @total_requests
end

.total_timeObject

Used for statistics (time-bandits for example)



61
62
63
# File 'lib/amiando.rb', line 61

def total_time
  @total_time
end

.verboseObject

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

.requestsObject



81
82
83
# File 'lib/amiando.rb', line 81

def requests
  @requests ||= []
end

.runObject

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

Parameters:

  • api (String)

    API key

  • block (Block)

    block to execute with the given key

Returns:

  • the result of the block



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