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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -4
- data/app/controllers/yext/api/agreements/add_request_controller.rb +6 -3
- data/app/controllers/yext/api/powerlistings/listing_controller.rb +62 -0
- data/config/routes.rb +4 -0
- data/lib/config/api.yml +1 -1
- data/lib/yext/api/concerns/account_relations.rb +8 -0
- data/lib/yext/api/enumerations/listing_status.rb +19 -0
- data/lib/yext/api/knowledge_api/powerlistings/listing.rb +59 -0
- data/lib/yext/api/knowledge_api/powerlistings/publisher.rb +25 -0
- data/lib/yext/api/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 231f74310029474a04fbd38792855a4fe2062ab6
|
4
|
+
data.tar.gz: 011a274982d38ae9da9014915f97ddf11c617650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 278829385446794d3fe4d9d59b34c9a21389996634c7e23629e5401a6f28cfb9bbef96d0d18c19b8e71454916b54c5134f85950eb95d9c8c4e6f2d7c48045dd1
|
7
|
+
data.tar.gz: 80a0f5606e80f15db7d90b89e0214cf482c340e0f3aa712f542f346705eb9e525fa8fe6070f25de4d6ccc7b1eeb23d395eb979a32e27d06b7dbf6d27cc451e71
|
data/Gemfile.lock
CHANGED
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.
|
109
|
+
ActiveSupport::Notifications.subscribe "add_request.knowledge_manager.yext", AddRequestChanged
|
110
110
|
|
111
111
|
# with a block:
|
112
|
-
ActiveSupport::Notifications.subscribe "add_request.
|
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.
|
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
|
9
|
-
#
|
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.
|
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
|
data/config/routes.rb
CHANGED
data/lib/config/api.yml
CHANGED
@@ -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
|
data/lib/yext/api/version.rb
CHANGED
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.
|
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-
|
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
|