Method: Osm::Api#initialize

Defined in:
lib/osm/api.rb

#initialize(user_id, secret, site = @@site) ⇒ Object

Initialize a new API connection

Parameters:

  • user_id (String)

    OSM userid of the user to act as (get this by using the authorize method)

  • secret (String)

    OSM secret of the user to act as (get this by using the authorize method)

  • site (Symbol) (defaults to: @@site)

    Whether to use OSM (:osm) or OGM (:ogm), defaults to the value set for the class

Raises:

  • (ArgumentError)


71
72
73
74
75
76
77
78
79
# File 'lib/osm/api.rb', line 71

def initialize(user_id, secret, site=@@site)
  raise ArgumentError, 'You must pass a secret (get this by using the authorize method)' if secret.nil?
  raise ArgumentError, 'You must pass a user_id (get this by using the authorize method)' if user_id.nil?
  raise ArgumentError, 'site is invalid, if passed it should be either :osm or :ogm, if not passed then you forgot to run Api.configure' unless [:osm, :ogm].include?(site)

  @site = site
  set_user(user_id, secret)
  nil
end