Class: Yext::Api::KnowledgeApi::KnowledgeManager::Location

Inherits:
Utils::ApiBase
  • Object
show all
Includes:
Concerns::AccountChild
Defined in:
lib/yext/api/knowledge_api/knowledge_manager/location.rb

Overview

:knowledge_api:

:knowledge_manager:
  :Location:
    - :action: :index
      :method: :get
      :endpoint: https://api.yext.com/v2/accounts/{accountId}/locations
      :path_regex: v2/accounts/[^/]+?/locations
      :default_version: 20161012
      :documentation: http://developer.yext.com/docs/api-reference/#operation/getLocations
      :sandbox_only: false
    - :action: :create
      :method: :post
      :endpoint: https://api.yext.com/v2/accounts/{accountId}/locations
      :path_regex: v2/accounts/[^/]+?/locations
      :default_version: 20161012
      :documentation: http://developer.yext.com/docs/api-reference/#operation/createLocation
      :sandbox_only: false
    - :action: :search
      :method: :get
      :endpoint: https://api.yext.com/v2/accounts/{accountId}/locationsearch
      :path_regex: v2/accounts/[^/]+?/locationsearch
      :default_version: 20161012
      :documentation: http://developer.yext.com/docs/api-reference/#operation/searchLocations
      :sandbox_only: false
    - :action: :show
      :method: :get
      :endpoint: https://api.yext.com/v2/accounts/{accountId}/locations/{locationId}
      :path_regex: v2/accounts/[^/]+?/locations/[^/]+??
      :default_version: 20161012
      :documentation: http://developer.yext.com/docs/api-reference/#operation/getLocation
      :sandbox_only: false
    - :action: :update
      :method: :put
      :endpoint: https://api.yext.com/v2/accounts/{accountId}/locations/{locationId}
      :path_regex: v2/accounts/[^/]+?/locations/[^/]+??
      :default_version: 20161012
      :documentation: http://developer.yext.com/docs/api-reference/#operation/updateLocation
      :sandbox_only: false

Instance Method Summary collapse

Methods included from Concerns::AccountChild

#accountId=, association_name, ensure_relation, with_account_path

Methods included from Concerns::FaradayConnection

faraday_connection

Instance Method Details

#add_services!(skus:, agreement_id: nil, force_review: false) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/yext/api/knowledge_api/knowledge_manager/location.rb', line 74

def add_services!(skus:, agreement_id: nil, force_review: false)
  args               = { existingAccountId: , existingLocationId: id }
  args[:skus]        = skus if skus.present?
  args[:agreementId] = agreement_id if agreement_id.present?
  args[:forceReview] = force_review if force_review.present?

  Yext::Api::AdministrativeApi::AddRequest.add_services!(args)
end

#cancel_services!(agreement_id: nil, skus: nil) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/yext/api/knowledge_api/knowledge_manager/location.rb', line 84

def cancel_services!(agreement_id: nil, skus: nil)
  args               = { locationId: id }
  args[:agreementId] = agreement_id if agreement_id.present?
  args[:skus]        = skus if skus.present?

  Yext::Api::AdministrativeApi::Service.cancel_services!(args)
end

#save(*fields_to_update) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/yext/api/knowledge_api/knowledge_manager/location.rb', line 59

def save(*fields_to_update)
  return super if fields_to_update.blank?

  # To save only certain fields, slice those fields into a new Location so that everything
  # is sent (which is only the fields we want)
  location = Yext::Api::KnowledgeApi::KnowledgeManager::Location.
      new(attributes.with_indifferent_access.slice(*fields_to_update))

  location.id        = id
  location.accountId = accountId

  location.save
end