lib/yext/api/administrative_api/service.rb in yext-api-0.1.1 vs lib/yext/api/administrative_api/service.rb in yext-api-0.1.3
- old
+ new
@@ -9,30 +9,52 @@
# - :action: :available
# :method: :get
# :endpoint: https://api.yext.com/v2/accounts/{accountId}/availableservices
# :default_version: 20161012
# :documentation: http://developer.yext.com/docs/administrative-api/#operation/listAvailableServices
- # :comment: Return list of services available to you under your agreements.
# :sandbox_only: false
# - :action: :index
# :method: :get
# :endpoint: https://api.yext.com/v2/accounts/{accountId}/services
# :default_version: 20161012
# :documentation: http://developer.yext.com/docs/administrative-api/#operation/listServices
- # :comment: Retrieve a list of all services provisioned through this account.
# :sandbox_only: false
# - :action: :destroy
# :method: :post
# :endpoint: https://api.yext.com/v2/accounts/{accountId}/cancelservices
# :default_version: 20161012
# :documentation: http://developer.yext.com/docs/administrative-api/#operation/cancelServices
- # :comment: Cancel one or more active services.
# :sandbox_only: false
class Service < Yext::Api::Utils::ApiBase
include Yext::Api::Concerns::AccountChild
scope :available, -> { with(Yext::Api::Concerns::AccountChild.with_account_path("availableservices")) }
- scope :cancel_services, -> { with(Yext::Api::Concerns::AccountChild.with_account_path("cancelservices")) }
+
+ # A method as scope to cancel services for a location. This feature is here because it is documented
+ # in the AdministrativeApi as basically a method on the Service concept.
+ #
+ # The Location contains an instance method to do this without having to pass in the
+ # arguments hash:
+ #
+ # Some examples of ways to add services:
+ # Yext::Api::AdministrativeApi::Service.cancel_services! locationId: location_id
+ # skus: [sku]
+ #
+ # location = Yext::KnowledgeApi::KnowledgeManager::Location.account(child_account_id).find(location_id)
+ # location.cancel_services! skus: [sku]
+ #
+ # location = Yext::KnowledgeApi::KnowledgeManager::Location.new(id: location_id)
+ # location.cancel_services! skus: [sku]
+ scope(:cancel_services!, lambda do |cancel_hash|
+ args = scope_args(true)
+
+ args.merge!(cancel_hash)
+
+ Yext::Api::AdministrativeApi::Account.
+ where(args).
+ with(:cancelservices).
+ post
+ end)
end
end
end
end