Class: Teleflow::Client
- Inherits:
-
Object
- Object
- Teleflow::Client
- Includes:
- HTTParty, Api::Blueprints, Api::Changes, Api::Connection, Api::Environments, Api::Events, Api::ExecutionDetails, Api::Feeds, Api::InboundParse, Api::Integrations, Api::Layouts, Api::Messages, Api::Notification, Api::NotificationGroups, Api::NotificationTemplates, Api::Organizations, Api::Subscribers, Api::Tenants, Api::Topics
- Defined in:
- lib/teleflow/client.rb
Instance Attribute Summary collapse
-
#enable_retry ⇒ Object
Returns the value of attribute enable_retry.
-
#idempotency_key ⇒ Object
Returns the value of attribute idempotency_key.
-
#initial_delay ⇒ Object
Returns the value of attribute initial_delay.
-
#max_delay ⇒ Object
Returns the value of attribute max_delay.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
Instance Method Summary collapse
-
#initialize(access_token: nil, idempotency_key: nil, enable_retry: false, retry_config: {}, backend_url: "https://api-teleflow.khulnasoft.com/v1") ⇒ Client
constructor
A new instance of Client.
Methods included from Api::Topics
#add_subscribers, #create_topic, #delete_topic, #remove_subscribers, #rename_topic, #subscriber_topic, #topic, #topics
Methods included from Api::Tenants
#create_tenant, #delete_tenant, #tenant, #tenants, #update_tenant
Methods included from Api::Subscribers
#bulk_create_subscribers, #chat_oauth, #create_subscriber, #delete_subscriber, #delete_subscriber_credentials, #mark_all_subscriber_messages, #mark_message_action_seen, #mark_subscriber_feed_seen, #provider_oauth_redirect, #subscriber, #subscriber_notification_feed, #subscriber_preferences, #subscriber_unseen_notification_count, #subscribers, #update_subscriber, #update_subscriber_credentials, #update_subscriber_online_status, #update_subscriber_preference
Methods included from Api::Organizations
#create_organization, #current_organization, #current_organization_members, #delete_organization_member, #organization_branding, #organizations, #rename_organization
Methods included from Api::Notification
#notification, #notifications, #notifications_graph_stats, #notifications_stats
Methods included from Api::NotificationTemplates
#create_notification_template, #create_notification_template_blueprint, #delete_notification_template, #notification_template, #notification_template_blueprint, #notification_templates, #update_notification_template, #update_notification_template_status
Methods included from Api::NotificationGroups
#create_notification_group, #notification_groups
Methods included from Api::Messages
Methods included from Api::Layouts
#create_layout, #delete_layout, #layout, #layouts, #make_default_layout, #update_layout
Methods included from Api::Integrations
#active_integrations, #channel_limit, #create_integration, #delete_integration, #in_app_status, #integrations, #set_integration_as_primary, #update_integration, #webhook_provider_status
Methods included from Api::InboundParse
#validate_mx_record_setup_for_inbound_parse
Methods included from Api::Feeds
#create_feed, #delete_feed, #feeds
Methods included from Api::ExecutionDetails
Methods included from Api::Events
#broadcast_event, #cancel_triggered_event, #trigger_bulk_event, #trigger_event
Methods included from Api::Environments
#api_keys, #create_environment, #current_environment, #environments, #regenerate_api_keys, #update_environment, #update_widget_settings
Methods included from Api::Connection
#delete, #get, #patch, #post, #put
Methods included from Api::Changes
#apply_bulk_changes, #apply_change, #changes, #count_changes
Methods included from Api::Blueprints
#get_blueprint, #group_blueprints_by_category
Constructor Details
#initialize(access_token: nil, idempotency_key: nil, enable_retry: false, retry_config: {}, backend_url: "https://api-teleflow.khulnasoft.com/v1") ⇒ Client
Returns a new instance of Client.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/teleflow/client.rb', line 56 def initialize(access_token: nil, idempotency_key: nil, enable_retry: false, retry_config: {}, backend_url: "https://api-teleflow.khulnasoft.com/v1") raise ArgumentError, "Api Key cannot be blank or nil" if access_token.blank? @idempotency_key = idempotency_key.blank? ? UUID.new.generate : idempotency_key @enable_retry = enable_retry @access_token = access_token.to_s.strip @retry_attempts = 0 retry_config = defaults_retry_config.merge(retry_config) @max_retries = retry_config[:max_retries] @initial_delay = retry_config[:initial_delay] @max_delay = retry_config[:max_delay] self.class.base_uri(backend_url) self.class..merge!(headers: { "Authorization" => "ApiKey #{@access_token}", "User-Agent" => "teleflow/ruby/#{Teleflow::VERSION}" } ) # Configure the exponential backoff - specifying initial and maximal delays, default is 4s and 60s respectively if @enable_retry @retry_config = retry_config @backoff = ExponentialBackoff.new(@initial_delay, @max_delay) end rescue ArgumentError => e puts "Error initializing Teleflow client: #{e.}" end |
Instance Attribute Details
#enable_retry ⇒ Object
Returns the value of attribute enable_retry.
47 48 49 |
# File 'lib/teleflow/client.rb', line 47 def enable_retry @enable_retry end |
#idempotency_key ⇒ Object
Returns the value of attribute idempotency_key.
47 48 49 |
# File 'lib/teleflow/client.rb', line 47 def idempotency_key @idempotency_key end |
#initial_delay ⇒ Object
Returns the value of attribute initial_delay.
47 48 49 |
# File 'lib/teleflow/client.rb', line 47 def initial_delay @initial_delay end |
#max_delay ⇒ Object
Returns the value of attribute max_delay.
47 48 49 |
# File 'lib/teleflow/client.rb', line 47 def max_delay @max_delay end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
47 48 49 |
# File 'lib/teleflow/client.rb', line 47 def max_retries @max_retries end |