zendesk_apps_support 1.29.2 → 1.30.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbc7a818e32400866027384bc77b49bc2ee8133b
4
- data.tar.gz: a66d4a56a160a192a6ec2272eb58ed84dc091411
3
+ metadata.gz: d4476b8e9538df6d66e4a9cccb93b03d633bf578
4
+ data.tar.gz: 568614d0401254083bc79846d34d19efe081c90c
5
5
  SHA512:
6
- metadata.gz: 3ced00c83f13d7e25721b2200648c6104b7db82b1f3b9aa3f181461ddbc39174d148903877292016e331d7fefa2cedc4304f1b670a81e3ff2941cedcc143506d
7
- data.tar.gz: 25a3b4fd8d46d00282d5210e48cc4fc21696d2f7e474c5bbbafcf6bcb3e724e06e850088055fb5c20c9977788a6f7b6195fe049553d801a9581e7fa37059453a
6
+ metadata.gz: 664b051da793aae6c5dbd5222384e3d5a663af29bba331291842d5486e98ee6713bd72dbb1c0766e0a067aed66d7eff0cd7a9d82595a08bb116718d4c2f7732e
7
+ data.tar.gz: 1c579b00dad7f5900bc8b87264ce95bcfe667a1183e24a9ffcc88171e1bb7ab9de2e3bc80b2dbb8f6f26cb2b399863b903b6d4d5308ca77ed19c2d2467360cb1
@@ -10,6 +10,7 @@ module ZendeskAppsSupport
10
10
  autoload :Package, 'zendesk_apps_support/package'
11
11
  autoload :Installed, 'zendesk_apps_support/installed'
12
12
  autoload :Installation, 'zendesk_apps_support/installation'
13
+ autoload :Finders, 'zendesk_apps_support/finders'
13
14
  autoload :AppRequirement, 'zendesk_apps_support/app_requirement'
14
15
  autoload :AppVersion, 'zendesk_apps_support/app_version'
15
16
  autoload :StylesheetCompiler, 'zendesk_apps_support/stylesheet_compiler'
@@ -0,0 +1,32 @@
1
+ module ZendeskAppsSupport
2
+ module Finders
3
+ class RecordNotFound < StandardError
4
+ def initialize(msg)
5
+ super(msg)
6
+ end
7
+ end
8
+
9
+ def find_by(arg)
10
+ all.find(&filter_by_arg(arg))
11
+ end
12
+
13
+ def find_by!(arg)
14
+ found = find_by(arg)
15
+ fail RecordNotFound.new("Unable to find #{self.name} with #{arg.inspect}") if found.nil?
16
+ found
17
+ end
18
+
19
+ def where(arg)
20
+ all.select(&filter_by_arg(arg))
21
+ end
22
+
23
+ private
24
+
25
+ def filter_by_arg(arg)
26
+ fail('More than one key-value pair found') if arg.size > 1
27
+ attribute, value = arg.to_a.first
28
+ value = value.to_s if value.is_a? Symbol
29
+ ->(product) { product.public_send(attribute) == value }
30
+ end
31
+ end
32
+ end
@@ -1,29 +1,33 @@
1
1
  module ZendeskAppsSupport
2
- module Location
3
- # the numbers below match the enum values on the database, do not change them!
4
- LOCATIONS_AVAILABLE = {
5
- 'zendesk' => {
6
- 'top_bar' => { 'id' => 1, 'orderable' => true },
7
- 'nav_bar' => { 'id' => 2, 'orderable' => true },
8
- 'ticket_sidebar' => { 'id' => 3, 'orderable' => true },
9
- 'new_ticket_sidebar' => { 'id' => 4, 'orderable' => true },
10
- 'user_sidebar' => { 'id' => 5, 'orderable' => true },
11
- 'organization_sidebar' => { 'id' => 6, 'orderable' => true },
12
- 'background' => { 'id' => 7, 'orderable' => false }
13
- },
14
- 'zopim' => {
15
- 'chat_sidebar' => { 'id' => 8, 'orderable' => false }
16
- }
17
- }.freeze
2
+ class Location
3
+ extend ZendeskAppsSupport::Finders
4
+ attr_reader :id, :name, :orderable, :product_code
18
5
 
19
- class << self
20
- def hosts
21
- LOCATIONS_AVAILABLE.keys
22
- end
6
+ def initialize(attrs)
7
+ @id = attrs.fetch(:id)
8
+ @name = attrs.fetch(:name)
9
+ @orderable = attrs.fetch(:orderable)
10
+ @product_code = attrs.fetch(:product_code)
11
+ end
12
+
13
+ def product
14
+ Product.find_by(code: product_code)
15
+ end
23
16
 
24
- def names_for(host)
25
- LOCATIONS_AVAILABLE[host.to_s].keys
26
- end
17
+ def self.all
18
+ LOCATIONS_AVAILABLE
27
19
  end
20
+
21
+ # the ids below match the enum values on the database, do not change them!
22
+ LOCATIONS_AVAILABLE = [
23
+ Location.new(id: 1, orderable: true, name: 'top_bar', product_code: Product::SUPPORT.code),
24
+ Location.new(id: 2, orderable: true, name: 'nav_bar', product_code: Product::SUPPORT.code),
25
+ Location.new(id: 3, orderable: true, name: 'ticket_sidebar', product_code: Product::SUPPORT.code),
26
+ Location.new(id: 4, orderable: true, name: 'new_ticket_sidebar', product_code: Product::SUPPORT.code),
27
+ Location.new(id: 5, orderable: true, name: 'user_sidebar', product_code: Product::SUPPORT.code),
28
+ Location.new(id: 6, orderable: true, name: 'organization_sidebar', product_code: Product::SUPPORT.code),
29
+ Location.new(id: 7, orderable: false, name: 'background', product_code: Product::SUPPORT.code),
30
+ Location.new(id: 8, orderable: false, name: 'chat_sidebar', product_code: Product::CHAT.code)
31
+ ].freeze
28
32
  end
29
33
  end
@@ -122,12 +122,14 @@ module ZendeskAppsSupport
122
122
  author = manifest_json['author']
123
123
  framework_version = manifest_json['frameworkVersion']
124
124
  single_install = manifest_json['singleInstall'] || false
125
+ signed_urls = manifest_json['signedUrls'] || false
125
126
  templates = is_no_template ? {} : compiled_templates(app_id, asset_url_prefix)
126
127
 
127
128
  app_settings = {
128
129
  location: locations,
129
130
  noTemplate: no_template_locations,
130
- singleInstall: single_install
131
+ singleInstall: single_install,
132
+ signedUrls: signed_urls
131
133
  }.select { |_k, v| !v.nil? }
132
134
 
133
135
  SRC_TEMPLATE.result(
@@ -1,15 +1,25 @@
1
1
  module ZendeskAppsSupport
2
- module Product
3
- # The product code below match the values in the database, do not change them!
2
+ class Product
3
+ extend ZendeskAppsSupport::Finders
4
+ attr_reader :code, :name, :legacy_name
5
+
6
+ def initialize(attrs)
7
+ @code = attrs.fetch(:code)
8
+ @name = attrs.fetch(:name)
9
+ @legacy_name = attrs.fetch(:legacy_name)
10
+ end
11
+
12
+ def self.all
13
+ PRODUCTS_AVAILABLE
14
+ end
15
+
16
+ # The product codes below match the values in the database, do not change them!
4
17
  PRODUCTS_AVAILABLE = [
5
- {
6
- code: 1,
7
- name: 'support',
8
- },
9
- {
10
- code: 2,
11
- name: 'chat',
12
- }
18
+ Product.new(code: 1, name: 'support', legacy_name: 'zendesk'),
19
+ Product.new(code: 2, name: 'chat', legacy_name: 'zopim')
13
20
  ].freeze
21
+
22
+ SUPPORT = find_by!(name: 'support')
23
+ CHAT = find_by!(name: 'chat')
14
24
  end
15
25
  end
@@ -102,9 +102,11 @@ module ZendeskAppsSupport
102
102
  errors = []
103
103
  manifest_locations = package.locations
104
104
  manifest_locations.find do |host, locations|
105
- error = if !Location.hosts.include?(host)
105
+ # CRUFT: remove when support for legacy names are deprecated
106
+ product = Product.find_by(legacy_name: host) || Product.find_by(name: host)
107
+ error = if product.nil?
106
108
  ValidationError.new(:invalid_host, host_name: host)
107
- elsif (invalid_locations = locations.keys - Location.names_for(host)).any?
109
+ elsif (invalid_locations = locations.keys - Location.where(product_code: product.code).map(&:name)).any?
108
110
  ValidationError.new(:invalid_location,
109
111
  invalid_locations: invalid_locations.join(', '),
110
112
  host_name: host,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_apps_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.29.2
4
+ version: 1.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-05-27 00:00:00.000000000 Z
14
+ date: 2016-07-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: i18n
@@ -160,6 +160,7 @@ files:
160
160
  - lib/zendesk_apps_support/assets/src.js.erb
161
161
  - lib/zendesk_apps_support/build_translation.rb
162
162
  - lib/zendesk_apps_support/engine.rb
163
+ - lib/zendesk_apps_support/finders.rb
163
164
  - lib/zendesk_apps_support/i18n.rb
164
165
  - lib/zendesk_apps_support/installation.rb
165
166
  - lib/zendesk_apps_support/installed.rb
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  version: 1.3.6
198
199
  requirements: []
199
200
  rubyforge_project:
200
- rubygems_version: 2.6.3
201
+ rubygems_version: 2.5.1
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: Support to help you develop Zendesk Apps.