lib/crowdskout/api.rb in crowdskout-0.1.2 vs lib/crowdskout/api.rb in crowdskout-0.1.3

- old
+ new

@@ -8,64 +8,64 @@ class Api # Class constructor # @param [String] api_key - Crowdskout API Key # @param [String] access_token - Crowdskout OAuth2 access token # @return - 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 == '' + 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 Services::BaseService.access_token.nil? || Services::BaseService.access_token == '' + if @access_token.nil? || @access_token == '' raise ArgumentError.new(Util::Config.get('errors.access_token_missing')) end end # Profile Service Methods def get_profile(profile_id, collections) - Services::ProfileService.get_profile(profile_id, collections) + Services::ProfileService.new(api_key, access_token).get_profile(profile_id, collections) end def create_profile(profile) - Services::ProfileService.create_profile(profile) + Services::ProfileService.new(api_key, access_token).create_profile(profile) end def create_profiles_bulk(profiles) - Services::ProfileService.create_profiles_bulk(profiles) + Services::ProfileService.new(api_key, access_token).create_profiles_bulk(profiles) end def update_profile(profile) - Services::ProfileService.update_profile(profile) + Services::ProfileService.new(api_key, access_token).update_profile(profile) end def update_profiles_bulk(profiles) - Services::ProfileService.update_profiles_bulk(profiles) + Services::ProfileService.new(api_key, access_token).update_profiles_bulk(profiles) end def check_for_non_match(profile) - Services::ProfileService.check_for_non_match(profile) + Services::ProfileService.new(api_key, access_token).check_for_non_match(profile) end # Fields Service Methods def get_options_for_a_field(field_name, params = {}) - Services::FieldService.get_options_for_a_field(field_name, params) + Services::FieldService.new(api_key, access_token).get_options_for_a_field(field_name, params) end # Attribute Service Methods def get_attributes(params = {}) - Services::AttributeService.get_attributes(params) + Services::AttributeService.new(api_key, access_token).get_attributes(params) end def get_attribute(attribute_id, params = {}) - Services::AttributeService.get_attribute(attribute_id) + Services::AttributeService.new(api_key, access_token).get_attribute(attribute_id) end def create_attribute(name, type, options = nil) - Services::AttributeService.create_attribute(name, type, options) + Services::AttributeService.new(api_key, access_token).create_attribute(name, type, options) end def update_attribute(attribute_id, params = {}) - Services::AttributeService.update_attribute(attribute_id, params) + Services::AttributeService.new(api_key, access_token).update_attribute(attribute_id, params) end def delete_attribute(attribute_id) - Services::AttributeService.delete_attribute(attribute_id) + Services::AttributeService.new(api_key, access_token).delete_attribute(attribute_id) end # Quartermaster Service Methods def tracking_code - Services::QuartermasterService.tracking_code + Services::QuartermasterService.new(api_key, access_token).tracking_code end end -end \ No newline at end of file +end