yext-api 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f99917453bea7720f49022c02cf64fd132944d33
4
- data.tar.gz: 89289aa7c0dbcf44ac8d10864ee995c71f0a3d24
3
+ metadata.gz: 231f74310029474a04fbd38792855a4fe2062ab6
4
+ data.tar.gz: 011a274982d38ae9da9014915f97ddf11c617650
5
5
  SHA512:
6
- metadata.gz: c43378a81d8ef44bfafdab12deb9fcc05c632dbac4ff9b29d1abb9d0d1f50b5d1aceb7b90975268001b99ca3cbac15fec08177ee1a7fbdc1f299e002f91d17ea
7
- data.tar.gz: 7d83de65e7fc052f52d129e73ae988359eacc34528e3f460f8483aa0793adb2d7be1e6cfe47785ec119fd2d0dae29d425300dd6dc5c898d33fbc808cc9ec1732
6
+ metadata.gz: 278829385446794d3fe4d9d59b34c9a21389996634c7e23629e5401a6f28cfb9bbef96d0d18c19b8e71454916b54c5134f85950eb95d9c8c4e6f2d7c48045dd1
7
+ data.tar.gz: 80a0f5606e80f15db7d90b89e0214cf482c340e0f3aa712f542f346705eb9e525fa8fe6070f25de4d6ccc7b1eeb23d395eb979a32e27d06b7dbf6d27cc451e71
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yext-api (0.1.7)
4
+ yext-api (0.1.8)
5
5
  memoist (~> 0)
6
6
  rails (> 4)
7
7
  spyke (~> 5)
data/README.md CHANGED
@@ -100,26 +100,30 @@ You can hook into notifications in multiple ways:
100
100
  ```ruby
101
101
  # with a class:
102
102
  class AddRequestChanged
103
- def call(name, started, finished, unique_id, data)
103
+ def self.call(name, started, finished, unique_id, data)
104
104
  params_hash = { name: name, started: started, finished: finished, unique_id: unique_id, data: data }
105
105
  Rails.logger.error "add_request_changed called: #{params_hash}"
106
106
  end
107
107
  end
108
108
 
109
- ActiveSupport::Notifications.subscribe "add_request.changed.yext", AddRequestChanged.new
109
+ ActiveSupport::Notifications.subscribe "add_request.knowledge_manager.yext", AddRequestChanged
110
110
 
111
111
  # with a block:
112
- ActiveSupport::Notifications.subscribe "add_request.changed.yext" do |name, started, finished, unique_id, data|
112
+ ActiveSupport::Notifications.subscribe "add_request.knowledge_manager.yext" do |name, started, finished, unique_id, data|
113
113
  end
114
114
  ```
115
115
 
116
116
  The following notifications will be
117
117
  instrumented with the indicated parameters:
118
118
 
119
- * add_request.changed.yext
119
+ * add_request.knowledge_manager.yext
120
120
  * **meta** - The meta information for the webhook
121
121
  * **add_request** - A Yext::Api::AdministrativeApi::AddRequest object of the changed AddRequest.
122
122
 
123
+ * listing.powerlistings.yext
124
+ * **meta** - The meta information for the webhook
125
+ * **listing** - A Yext::Api::KnowledgeApi::Powerlistings::Listing object of the changed Listing.
126
+
123
127
  ### General Usage
124
128
 
125
129
  The API namespaces are setup to mimic the structure of the Yext API documentation to make it easier
@@ -5,8 +5,11 @@ module Yext
5
5
  module Agreements
6
6
  # This controller processes Yext add_request webhook callbacks.
7
7
  #
8
- # The controller will call the add_request_changed function on the configured class
9
- # for the add_request_changed function.
8
+ # The controller will instrument the "add_request.knowledge_manager.yext" ActiveSupport Notification.
9
+ # The params hash will include:
10
+ # * meta - the `meta` value of the webhook.
11
+ # * add_request - a Yext::Api::AdministrativeApi::AddRequest object that is the AddRequest
12
+ # being reported on.
10
13
 
11
14
  # :webhooks:
12
15
  # :agreements:
@@ -21,7 +24,7 @@ module Yext
21
24
  def create
22
25
  add_request = Yext::Api::AdministrativeApi::AddRequest.new(add_request_hash[:addRequest])
23
26
 
24
- ActiveSupport::Notifications.instrument "add_request.changed.yext",
27
+ ActiveSupport::Notifications.instrument "add_request.knowledge_manager.yext",
25
28
  meta: add_request_hash[:meta],
26
29
  add_request: add_request do
27
30
  # do your custom stuff here
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yext
4
+ module Api
5
+ module Powerlistings
6
+ # This controller processes Yext listing webhook callbacks.
7
+ #
8
+ # The controller will instrument the "listing.powerlistings.yext" ActiveSupport Notification.
9
+ # The params hash will include:
10
+ # * meta - the `meta` value of the webhook.
11
+ # * listing - a Yext::Api::KnowledgeApi::Powerlistings::Listing object that is the Listing
12
+ # being reported on.
13
+
14
+ # :webhooks:
15
+ # :listing:
16
+ # :endpoint: https://[your_hostname]/[your_listings_webhook_path]
17
+ # :default_version: 20161012
18
+ # :documentation: http://developer.yext.com/docs/webhooks/#operation/listingsWebhook
19
+ # :sandbox_only: false
20
+ class ListingController < Yext::Api::ApplicationController
21
+ extend Memoist
22
+
23
+ def create
24
+ listing = Yext::Api::KnowledgeApi::Powerlistings::Listing.new(listing_hash[:listing])
25
+
26
+ ActiveSupport::Notifications.instrument "listing.powerlistings.yext",
27
+ meta: listing_hash[:meta],
28
+ listing: listing do
29
+ # do your custom stuff here
30
+ end
31
+
32
+ head :ok
33
+ end
34
+
35
+ private
36
+
37
+ # rubocop:disable MethodLength
38
+
39
+ def listing_hash
40
+ params.
41
+ permit(meta: %i[eventType uuid timestamp accountId actor appSpecificAccountId],
42
+ listing: [:id,
43
+ :locationId,
44
+ :publisherId,
45
+ :status,
46
+ :additionalStatus,
47
+ :listingUrl,
48
+ :loginUrl,
49
+ :screenshotUrl,
50
+ { statusDetails: %i[code message type] },
51
+ { alternateBrands: %i[brandName listingUrl] }]).
52
+ to_hash.
53
+ with_indifferent_access
54
+ end
55
+
56
+ # rubocop:enable MethodLength
57
+
58
+ memoize :listing_hash
59
+ end
60
+ end
61
+ end
62
+ end
@@ -4,4 +4,8 @@ Yext::Api::Engine.routes.draw do
4
4
  scope :agreements, module: :agreements do
5
5
  resources :add_request, only: %i[create]
6
6
  end
7
+
8
+ scope :powerlistings, module: :powerlistings do
9
+ resources :listing, only: %i[create]
10
+ end
7
11
  end
@@ -420,7 +420,7 @@
420
420
  :documentation: http://developer.yext.com/docs/api-reference/#operation/deleteAsset
421
421
  :sandbox_only: false
422
422
  :power_listings:
423
- :module_name: PowerListings
423
+ :module_name: Powerlistings
424
424
  :objects:
425
425
  :publishser:
426
426
  :actions:
@@ -34,6 +34,14 @@ module Yext
34
34
  class_name: "Yext::Api::KnowledgeApi::OptimizationTasks::OptimizationLink",
35
35
  uri: Yext::Api::Concerns::AccountChild.with_account_path("optimizationlink")
36
36
 
37
+ # KnowledgeApi::Powerlistings
38
+ has_many :listings,
39
+ class_name: "Yext::Api::KnowledgeApi::Powerlistings::Listing",
40
+ uri: Yext::Api::Concerns::AccountChild.with_account_path("powerlistings/listings/(:id)")
41
+ has_many :publishers,
42
+ class_name: "Yext::Api::KnowledgeApi::Powerlistings::Publisher",
43
+ uri: Yext::Api::Concerns::AccountChild.with_account_path("powerlistings/publishers/(:id)")
44
+
37
45
  # LiveApi
38
46
  has_many :live_locations, class_name: "Yext::Api::LiveApi::Location"
39
47
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yext
4
+ module Api
5
+ module Enumerations
6
+ # An enumeration class to contain the possible status values for a listing.
7
+ class ListingStatus
8
+ include Yext::Api::Concerns::EnumAll
9
+
10
+ WAITING_ON_YEXT = "WAITING_ON_YEXT"
11
+ WAITING_ON_CUSTOMER = "WAITING_ON_CUSTOMER"
12
+ WAITING_ON_PUBLISHER = "WAITING_ON_PUBLISHER"
13
+ LIVE = "LIVE"
14
+ UNAVAILABLE = "UNAVAILABLE"
15
+ OPTED_OUT = "OPTED_OUT"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yext
4
+ module Api
5
+ module KnowledgeApi
6
+ module Powerlistings
7
+ # :knowledge_api:
8
+ # :powerlistings:
9
+ # :listing:
10
+ # - :action: :index
11
+ # :method: :get
12
+ # :endpoint: https://api.yext.com/v2/accounts/{accountId}/powerlistings/listings
13
+ # :path_regex: v2/accounts/[^/]+?/powerlistings/listings
14
+ # :default_version: 20161012
15
+ # :documentation: http://developer.yext.com/docs/api-reference/#operation/listListings
16
+ # :sandbox_only: false
17
+ # - :action: :opt_in
18
+ # :method: :put
19
+ # :endpoint: https://api.yext.com/v2/accounts/{accountId}/powerlistings/listings/optin
20
+ # :path_regex: v2/accounts/[^/]+?/powerlistings/listings/optin
21
+ # :default_version: 20161012
22
+ # :documentation: http://developer.yext.com/docs/api-reference/#operation/optInListings
23
+ # :sandbox_only: false
24
+ # - :action: :opt_out
25
+ # :method: :put
26
+ # :endpoint: https://api.yext.com/v2/accounts/{accountId}/powerlistings/listings/optout
27
+ # :path_regex: v2/accounts/[^/]+?/powerlistings/listings/optout
28
+ # :default_version: 20161012
29
+ # :documentation: http://developer.yext.com/docs/api-reference/#operation/optOutListings
30
+ # :sandbox_only: false
31
+ class Listing < Yext::Api::Utils::ApiBase
32
+ uri "powerlistings/#{default_uri}"
33
+
34
+ include Yext::Api::Concerns::AccountChild
35
+
36
+ # rubocop:disable Style/Lambda
37
+
38
+ scope(:opt_in!, ->(location_ids: nil, publisher_ids: nil) do
39
+ params = {}
40
+ params[:locationIds] = Array.wrap(location_ids).join(",") if location_ids.present?
41
+ params[:publisherIds] = Array.wrap(publisher_ids).join(",") if publisher_ids.present?
42
+
43
+ where(params).with(:optin).put
44
+ end)
45
+
46
+ scope(:opt_out!, ->(location_ids: nil, publisher_ids: nil) do
47
+ params = {}
48
+ params[:locationIds] = Array.wrap(location_ids) if location_ids.present?
49
+ params[:publisherIds] = Array.wrap(publisher_ids) if publisher_ids.present?
50
+
51
+ where(params).with(:optout).put
52
+ end)
53
+
54
+ # rubocop:enable Style/Lambda
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yext
4
+ module Api
5
+ module KnowledgeApi
6
+ module Powerlistings
7
+ # :knowledge_api:
8
+ # :powerlistings:
9
+ # :listing:
10
+ # - :action: :index
11
+ # :method: :get
12
+ # :endpoint: https://api.yext.com/v2/accounts/{accountId}/powerlistings/publishers
13
+ # :path_regex: v2/accounts/[^/]+?/powerlistings/publishers
14
+ # :default_version: 20161012
15
+ # :documentation: http://developer.yext.com/docs/api-reference/#operation/listPublishers
16
+ # :sandbox_only: false
17
+ class Publisher < Yext::Api::Utils::ApiBase
18
+ uri "powerlistings/#{default_uri}"
19
+
20
+ include Yext::Api::Concerns::AccountChild
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yext
4
4
  module Api
5
- VERSION = "0.1.7"
5
+ VERSION = "0.1.8"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yext-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - CardTapp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memoist
@@ -240,6 +240,7 @@ files:
240
240
  - Rakefile
241
241
  - app/controllers/yext/api/agreements/add_request_controller.rb
242
242
  - app/controllers/yext/api/application_controller.rb
243
+ - app/controllers/yext/api/powerlistings/listing_controller.rb
243
244
  - bin/console
244
245
  - bin/rails
245
246
  - bin/setup
@@ -278,6 +279,7 @@ files:
278
279
  - lib/yext/api/enumerations/error_codes/subscriptions_errors.rb
279
280
  - lib/yext/api/enumerations/error_codes/suppression_errors.rb
280
281
  - lib/yext/api/enumerations/error_codes/users_errors.rb
282
+ - lib/yext/api/enumerations/listing_status.rb
281
283
  - lib/yext/api/enumerations/location_type.rb
282
284
  - lib/yext/api/enumerations/optimization_link_mode.rb
283
285
  - lib/yext/api/enumerations/validation.rb
@@ -290,6 +292,8 @@ files:
290
292
  - lib/yext/api/knowledge_api/knowledge_manager/location.rb
291
293
  - lib/yext/api/knowledge_api/optimization_tasks/optimization_link.rb
292
294
  - lib/yext/api/knowledge_api/optimization_tasks/optimization_task.rb
295
+ - lib/yext/api/knowledge_api/powerlistings/listing.rb
296
+ - lib/yext/api/knowledge_api/powerlistings/publisher.rb
293
297
  - lib/yext/api/live_api.rb
294
298
  - lib/yext/api/live_api/location.rb
295
299
  - lib/yext/api/utils/api_base.rb