Module: WhatsAppCloudApi::Types
- Defined in:
- lib/whatsapp_cloud_api/types.rb
Defined Under Namespace
Classes: BusinessProfileEntry, CallActionResponse, CallConnectResponse, CallRecord, ContactRecord, ConversationRecord, GraphPaging, GraphSuccessResponse, MediaMetadataResponse, MediaUploadResponse, MessageContact, MessageInfo, MessageTemplate, PagedResponse, SendMessageResponse, TemplateCreateResponse
Constant Summary collapse
- MESSAGE_STATUSES =
Message status types
%w[accepted held_for_quality_assessment].freeze
- TEMPLATE_STATUSES =
Template status types
%w[APPROVED PENDING REJECTED PAUSED IN_APPEAL DISABLED].freeze
- TEMPLATE_CATEGORIES =
Template categories
%w[MARKETING UTILITY AUTHENTICATION UNKNOWN].freeze
- MEDIA_TYPES =
Media types
%w[image audio video document sticker].freeze
- INTERACTIVE_TYPES =
Interactive message types
%w[button list product product_list flow address location_request call_permission].freeze
Class Method Summary collapse
-
.deep_camel_case_keys(obj) ⇒ Object
Deep convert hash keys from snake_case to camelCase.
-
.deep_snake_case_keys(obj) ⇒ Object
Deep convert hash keys from camelCase to snake_case.
-
.to_camel_case(str) ⇒ Object
Utility method to convert snake_case to camelCase for API requests.
-
.to_snake_case(str) ⇒ Object
Utility method to convert camelCase to snake_case for Ruby conventions.
Class Method Details
.deep_camel_case_keys(obj) ⇒ Object
Deep convert hash keys from snake_case to camelCase
251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/whatsapp_cloud_api/types.rb', line 251 def self.deep_camel_case_keys(obj) case obj when Hash obj.transform_keys { |key| to_camel_case(key.to_s) } .transform_values { |value| deep_camel_case_keys(value) } when Array obj.map { |item| deep_camel_case_keys(item) } else obj end end |
.deep_snake_case_keys(obj) ⇒ Object
Deep convert hash keys from camelCase to snake_case
238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/whatsapp_cloud_api/types.rb', line 238 def self.deep_snake_case_keys(obj) case obj when Hash obj.transform_keys { |key| to_snake_case(key.to_s) } .transform_values { |value| deep_snake_case_keys(value) } when Array obj.map { |item| deep_snake_case_keys(item) } else obj end end |
.to_camel_case(str) ⇒ Object
Utility method to convert snake_case to camelCase for API requests
228 229 230 |
# File 'lib/whatsapp_cloud_api/types.rb', line 228 def self.to_camel_case(str) str.split('_').map.with_index { |word, i| i == 0 ? word : word.capitalize }.join end |
.to_snake_case(str) ⇒ Object
Utility method to convert camelCase to snake_case for Ruby conventions
233 234 235 |
# File 'lib/whatsapp_cloud_api/types.rb', line 233 def self.to_snake_case(str) str.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '') end |