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.6.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Api key to be used at all times.



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

def api_key
  @api_key
end

.autorunObject

If set to true, will run the requests automatically when needed.



53
54
55
# File 'lib/amiando.rb', line 53

def autorun
  @autorun
end

.base_urlString

Returns the url for the environment.

Returns:

  • (String)

    the url for the environment



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

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

.default_optionsObject

Set default options for typhoeus



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

def default_options
  @default_options
end

.loggerObject

Logger instance. There’s no logger by default.



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

def logger
  @logger
end

.timeoutObject

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



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

def timeout
  @timeout
end

.verboseObject

Returns the value of attribute verbose.



50
51
52
# File 'lib/amiando.rb', line 50

def verbose
  @verbose
end

Class Method Details

.development!Object

Connect to the test server (default)



73
74
75
# File 'lib/amiando.rb', line 73

def development!
  @production = false
end

.production!Object

Connect to the production server



68
69
70
# File 'lib/amiando.rb', line 68

def production!
  @production = true
end

.requestsObject



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

def requests
  @requests ||= []
end

.runObject

Runs all queued requests



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/amiando.rb', line 87

def run
  exception = nil
  requests.each { |request| hydra.queue(request) }

  ActiveSupport::Notifications.instrument("run.amiando", :calls => requests.size) do
    begin
      hydra.run
    rescue Exception => exception
    end
  end

  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



109
110
111
112
113
114
115
# File 'lib/amiando.rb', line 109

def with_key(key)
  old_key = Amiando.api_key
  Amiando.api_key = key
  yield
ensure
  Amiando.api_key = old_key
end