bobot 4.2.0 → 4.3.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: 7af564ff6f453c5af790ba23368eb1892d062f81
4
- data.tar.gz: f49364760f36e75c84c8a15d4126292b5df6ad49
3
+ metadata.gz: '05997a394695a17e1556d394d5d69b3ed289685e'
4
+ data.tar.gz: aaf7e1d426dc7d62d2525088293a07163cc9b8ba
5
5
  SHA512:
6
- metadata.gz: ba789253921a8122802674fb1f9d35638c24c8d5fa59c4017e62d0c454a4c02853f2f4037a33dbce91f5cb07660bb0c3eb4085a5d89ee2f1a6c2ff7f3ef25cd3
7
- data.tar.gz: fe4e0eafd52a377fb2465ce8a37afe59b278aeae7713bc866ebb00dca0923b6f26579bf70fc03e545538082766aeef6a9f72b0bedd2229489aa708c4d6130b99
6
+ metadata.gz: 3465a834b5f9169b5651f93045a07e6215b9fce540cd0d26c4549d38472853f109bc7bdf03b010bc5a299ee3e9527f51551882708e687e74e87760ff865bf039
7
+ data.tar.gz: 7ace1d8e14922d580b56f5bf68528a1d73224d2886b689fb6a4c7eacc6e056f82f129ea1d6ca06257d61e233399c58e56612d8ffd3ec337b353da1efb6acc984
data/lib/bobot/buttons.rb CHANGED
@@ -24,7 +24,7 @@ module Bobot
24
24
  }
25
25
  end
26
26
 
27
- def self.generic_element(title:, subtitle: nil, image_url: nil, default_action_url: nil, buttons: nil)
27
+ def self.generic_element(title:, subtitle: nil, image_url: nil, default_action: nil, buttons: nil)
28
28
  raise Bobot::FieldFormat.new('title is required') unless title.present?
29
29
  raise Bobot::FieldFormat.new('title size is limited to 80', "#{title} (#{title.size} chars)") if title.size > 80
30
30
  raise Bobot::FieldFormat.new('subtitle size is limited to 80', "#{subtitle} (#{subtitle.size} chars)") if subtitle.present? && subtitle.size > 80
@@ -34,11 +34,11 @@ module Bobot
34
34
  }.tap do |properties|
35
35
  properties[:image_url] = image_url if image_url.present?
36
36
  properties[:subtitle] = subtitle if subtitle.present?
37
- properties[:default_action_url] = default_action_url if default_action_url.present?
37
+ properties[:default_action] = default_action if default_action.present?
38
38
  properties[:buttons] = buttons if buttons.present?
39
39
  end
40
40
  end
41
- class <<self
41
+ class << self
42
42
  alias_method :carousel_element, :generic_element
43
43
  end
44
44
 
@@ -72,10 +72,6 @@ module Bobot
72
72
  end
73
73
 
74
74
  def self.share_custom(title:, subtitle:, image_url:, web_url:, button_title:, image_aspect_ratio: "square")
75
- raise Bobot::FieldFormat.new('title is required') unless title.present?
76
- raise Bobot::FieldFormat.new('title size is limited to 80', "#{title} (#{title.size} chars)") if title.size > 80
77
- raise Bobot::FieldFormat.new('subtitle is required') unless subtitle.present?
78
- raise Bobot::FieldFormat.new('subtitle size is limited to 80', "#{subtitle} (#{subtitle.size} chars)") if subtitle.size > 80
79
75
  raise Bobot::FieldFormat.new('button_title is required') unless button_title.present?
80
76
  raise Bobot::FieldFormat.new('button_title size is limited to 20', "#{button_title} (#{button_title.size} chars)") if button_title.size > 20
81
77
  {
@@ -87,22 +83,13 @@ module Bobot
87
83
  template_type: 'generic',
88
84
  image_aspect_ratio: image_aspect_ratio,
89
85
  elements: [
90
- {
86
+ self.generic_element(
91
87
  title: title,
92
88
  subtitle: subtitle,
93
89
  image_url: image_url,
94
- default_action: {
95
- type: 'web_url',
96
- url: web_url,
97
- },
98
- buttons: [
99
- {
100
- type: 'web_url',
101
- url: web_url,
102
- title: button_title,
103
- },
104
- ],
105
- },
90
+ default_action: self.default_action(url: web_url),
91
+ buttons: [ self.url(title: button_title, url: web_url) ]
92
+ )
106
93
  ],
107
94
  },
108
95
  },
@@ -110,7 +97,7 @@ module Bobot
110
97
  }
111
98
  end
112
99
 
113
- def self.default_action_url(url:, options: {})
100
+ def self.default_action(url:, options: {})
114
101
  raise Bobot::FieldFormat.new('url is required') unless url.present?
115
102
  if options.key?(:messenger_extensions) && options[:messenger_extensions] && !url.include?('https')
116
103
  raise Bobot::FieldFormat.new('must use url HTTPS protocol if messenger_extensions is true.', url)
@@ -3,7 +3,7 @@ require "uri"
3
3
 
4
4
  module Bobot
5
5
  module GraphFacebook
6
- GRAPH_FB_URL = 'https://graph.facebook.com/v2.11'.freeze
6
+ GRAPH_FB_URL = 'https://graph.facebook.com/v3.1'.freeze
7
7
  GRAPH_HEADERS = { Accept: "application/json", "Content-Type" => "application/json; charset=utf-8" }.freeze
8
8
 
9
9
  module ClassMethods
@@ -16,8 +16,10 @@ module Bobot
16
16
  ssl_verifypeer: false,
17
17
  )
18
18
  json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
19
- Rails.logger.debug "[GET] >> #{url}"
20
- Rails.logger.debug "[GET] << #{json}"
19
+ unless Rails.env.production?
20
+ Rails.logger.debug "[GET] >> #{url}"
21
+ Rails.logger.debug "[GET] << #{json}"
22
+ end
21
23
  Bobot::ErrorParser.raise_errors_from(json)
22
24
  json
23
25
  end
@@ -33,8 +35,10 @@ module Bobot
33
35
  ssl_verifypeer: false,
34
36
  )
35
37
  json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
36
- Rails.logger.debug "[POST] >> #{url}"
37
- Rails.logger.debug "[POST] << #{json}"
38
+ unless Rails.env.production?
39
+ Rails.logger.debug "[POST] >> #{url}"
40
+ Rails.logger.debug "[POST] << #{json}"
41
+ end
38
42
  Bobot::ErrorParser.raise_errors_from(json)
39
43
  json
40
44
  end
@@ -50,8 +54,10 @@ module Bobot
50
54
  ssl_verifypeer: false,
51
55
  )
52
56
  json = ActiveSupport::JSON.decode(response.send(:body) || '{}')
53
- Rails.logger.debug "[DELETE] >> #{url}"
54
- Rails.logger.debug "[DELETE] << #{json}"
57
+ unless Rails.env.production?
58
+ Rails.logger.debug "[DELETE] >> #{url}"
59
+ Rails.logger.debug "[DELETE] << #{json}"
60
+ end
55
61
  Bobot::ErrorParser.raise_errors_from(json)
56
62
  json
57
63
  end
data/lib/bobot/page.rb CHANGED
@@ -314,7 +314,7 @@ module Bobot
314
314
  def set_greeting_text!
315
315
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
316
316
  greeting_texts = []
317
- if language.nil?
317
+ if self.language.nil?
318
318
  # Default text
319
319
  greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: I18n.default_locale, default: nil)
320
320
  greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present?
data/lib/bobot/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Bobot
2
2
  class Version
3
3
  MAJOR = 4
4
- MINOR = 2
4
+ MINOR = 3
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Navid EMAD
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-17 00:00:00.000000000 Z
11
+ date: 2018-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n