Class: Crowdskout::Api

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

Instance Attribute Summary collapse

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



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

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

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



9
10
11
# File 'lib/crowdskout/api.rb', line 9

def access_token
  @access_token
end

#api_keyObject

Returns the value of attribute api_key.



9
10
11
# File 'lib/crowdskout/api.rb', line 9

def api_key
  @api_key
end

Instance Method Details

#check_for_non_match(profile) ⇒ Object



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

def check_for_non_match(profile)
  Services::ProfileService.new(@api_key, @access_token).check_for_non_match(profile)
end

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



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

def create_attribute(name, type, options = nil)
  Services::AttributeService.new(@api_key, @access_token).create_attribute(name, type, options)
end

#create_profile(profile) ⇒ Object



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

def create_profile(profile)
  Services::ProfileService.new(@api_key, @access_token).create_profile(profile)
end

#create_profiles_bulk(profiles) ⇒ Object



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

def create_profiles_bulk(profiles)
  Services::ProfileService.new(@api_key, @access_token).create_profiles_bulk(profiles)
end

#delete_attribute(attribute_id) ⇒ Object



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

def delete_attribute(attribute_id)
  Services::AttributeService.new(@api_key, @access_token).delete_attribute(attribute_id)
end

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



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

def get_attribute(attribute_id, params = {})
  Services::AttributeService.new(@api_key, @access_token).get_attribute(attribute_id)
end

#get_attributes(params = {}) ⇒ Object

Attribute Service Methods



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

def get_attributes(params = {})
  Services::AttributeService.new(@api_key, @access_token).get_attributes(params)
end

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

Fields Service Methods



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

def get_options_for_a_field(field_name, params = {})
  Services::FieldService.new(@api_key, @access_token).get_options_for_a_field(field_name, params)
end

#get_profile(profile_id, collections) ⇒ Object

Profile Service Methods



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

def get_profile(profile_id, collections)
  Services::ProfileService.new(@api_key, @access_token).get_profile(profile_id, collections)
end

#tracking_codeObject

Quartermaster Service Methods



69
70
71
# File 'lib/crowdskout/api.rb', line 69

def tracking_code
  Services::QuartermasterService.new(@api_key, @access_token).tracking_code
end

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



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

def update_attribute(attribute_id, params = {})
  Services::AttributeService.new(@api_key, @access_token).update_attribute(attribute_id, params)
end

#update_profile(profile) ⇒ Object



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

def update_profile(profile)
  Services::ProfileService.new(@api_key, @access_token).update_profile(profile)
end

#update_profiles_bulk(profiles) ⇒ Object



39
40
41
# File 'lib/crowdskout/api.rb', line 39

def update_profiles_bulk(profiles)
  Services::ProfileService.new(@api_key, @access_token).update_profiles_bulk(profiles)
end