Class: Crowdskout::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/crowdskout/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key = nil, access_token = nil) ⇒ Object

Class constructor

Parameters:

  • api_key (String) (defaults to: nil)
    • Crowdskout API Key

  • access_token (String) (defaults to: nil)
    • Crowdskout OAuth2 access token



13
14
15
16
17
18
19
20
21
22
# File 'lib/crowdskout/api.rb', line 13

def initialize(api_key = nil, access_token = nil)
  Services::BaseService.api_key = api_key || Util::Config.get('auth.api_key')
  Services::BaseService.access_token = access_token
  if Services::BaseService.api_key.nil? || Services::BaseService.api_key == ''
    raise ArgumentError.new(Util::Config.get('errors.api_key_missing'))
  end
  if Services::BaseService.access_token.nil? || Services::BaseService.access_token == ''
    raise ArgumentError.new(Util::Config.get('errors.access_token_missing'))
  end
end

Instance Method Details

#create_attribute(name, type, options = nil) ⇒ Object



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

def create_attribute(name, type, options = nil)
  Services::AttributeService.create_attribute(name, type, options)
end

#create_profile(profile) ⇒ Object



28
29
30
# File 'lib/crowdskout/api.rb', line 28

def create_profile(profile)
  Services::ProfileService.create_profile(profile)
end

#create_profiles_bulk(profiles) ⇒ Object



31
32
33
# File 'lib/crowdskout/api.rb', line 31

def create_profiles_bulk(profiles)
  Services::ProfileService.create_profiles_bulk(profiles)
end

#delete_attribute(attribute_id) ⇒ Object



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

def delete_attribute(attribute_id)
  Services::AttributeService.delete_attribute(attribute_id)
end

#get_attribute(attribute_id, params = {}) ⇒ Object



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

def get_attribute(attribute_id, params = {})
  Services::AttributeService.get_attribute(attribute_id)
end

#get_attributes(params = {}) ⇒ Object

Attribute Service Methods



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

def get_attributes(params = {})
  Services::AttributeService.get_attributes(params)
end

#get_options_for_a_field(field_name, params = {}) ⇒ Object

Fields Service Methods



42
43
44
# File 'lib/crowdskout/api.rb', line 42

def get_options_for_a_field(field_name, params = {})
  Services::FieldService.get_options_for_a_field(field_name, params)
end

#get_profile(profile_id, collections) ⇒ Object

Profile Service Methods



25
26
27
# File 'lib/crowdskout/api.rb', line 25

def get_profile(profile_id, collections)
  Services::ProfileService.get_profile(profile_id, collections)
end

#tracking_codeObject

Quartermaster Service Methods



64
65
66
# File 'lib/crowdskout/api.rb', line 64

def tracking_code
  Services::QuartermasterService.tracking_code
end

#update_attribute(attribute_id, params = {}) ⇒ Object



56
57
58
# File 'lib/crowdskout/api.rb', line 56

def update_attribute(attribute_id, params = {})
  Services::AttributeService.update_attribute(attribute_id, params)
end

#update_profile(profile) ⇒ Object



34
35
36
# File 'lib/crowdskout/api.rb', line 34

def update_profile(profile)
  Services::ProfileService.update_profile(profile)
end

#update_profiles_bulk(profiles) ⇒ Object



37
38
39
# File 'lib/crowdskout/api.rb', line 37

def update_profiles_bulk(profiles)
  Services::ProfileService.update_profiles_bulk(profiles)
end