Class: Inttegro::Broadcast::Request

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/inttegro/broadcast/request.rb

Overview

Typed representation of the request object in the Inttegro API.

This generated model is immutable. Construct it with .new, or decode a string-keyed API payload with .from_hash. #serialize produces a string-keyed hash using the original wire field names and serialized enum values.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#email ⇒ Inttegro::Chime::EmailMessageInput? (readonly)

Email content accepted for email chimes, broadcasts, and schedules.

Optional in the API payload; omitted values default to nil. Wire name: email.



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
86
87
88
89
90
# File 'lib/inttegro/broadcast/request.rb', line 61

class Request < T::Struct
  const :request_meta, T.nilable(Inttegro::Broadcast::RequestRequestMeta), default: nil
  const :message_template, T.nilable(T.any(String, Inttegro::MessageTemplate::Reference)), default: nil
  const :email, T.nilable(Inttegro::Chime::EmailMessageInput), default: nil
  const :purpose, T.nilable(String), default: nil
  const :recipients, T::Array[T.any(Inttegro::Chime::PhoneRecipient, Inttegro::Chime::EmailRecipient, Inttegro::Chime::SavedCustomerRecipient)]
  const :sender, T.nilable(String), default: nil

  extend T::Sig

  sig { params(hash: T::Hash[String, Object], strict: T::Boolean).returns(T.attached_class) }
  def self.from_hash(hash, strict = false)
    data = hash.dup
    if (recipients_value = data["recipients"]).is_a?(Array)
      data["recipients"] = recipients_value.map do |item|
        next item unless item.is_a?(Hash)
        if item.key?("phone")
          Inttegro::Chime::PhoneRecipient.from_hash(item)
        elsif item.key?("email")
          Inttegro::Chime::EmailRecipient.from_hash(item)
        elsif item.key?("customer_id")
          Inttegro::Chime::SavedCustomerRecipient.from_hash(item)
        else
          item
        end
      end
    end
    super(data, strict)
  end
end

#message_template ⇒ String, ... (readonly)

Raw SMS content for SMS broadcasts, or a stored message template reference for SMS or email broadcasts.

Optional in the API payload; omitted values default to nil. Wire name: message_template.

Returns:



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
86
87
88
89
90
# File 'lib/inttegro/broadcast/request.rb', line 61

class Request < T::Struct
  const :request_meta, T.nilable(Inttegro::Broadcast::RequestRequestMeta), default: nil
  const :message_template, T.nilable(T.any(String, Inttegro::MessageTemplate::Reference)), default: nil
  const :email, T.nilable(Inttegro::Chime::EmailMessageInput), default: nil
  const :purpose, T.nilable(String), default: nil
  const :recipients, T::Array[T.any(Inttegro::Chime::PhoneRecipient, Inttegro::Chime::EmailRecipient, Inttegro::Chime::SavedCustomerRecipient)]
  const :sender, T.nilable(String), default: nil

  extend T::Sig

  sig { params(hash: T::Hash[String, Object], strict: T::Boolean).returns(T.attached_class) }
  def self.from_hash(hash, strict = false)
    data = hash.dup
    if (recipients_value = data["recipients"]).is_a?(Array)
      data["recipients"] = recipients_value.map do |item|
        next item unless item.is_a?(Hash)
        if item.key?("phone")
          Inttegro::Chime::PhoneRecipient.from_hash(item)
        elsif item.key?("email")
          Inttegro::Chime::EmailRecipient.from_hash(item)
        elsif item.key?("customer_id")
          Inttegro::Chime::SavedCustomerRecipient.from_hash(item)
        else
          item
        end
      end
    end
    super(data, strict)
  end
end

#purpose ⇒ String? (readonly)

Category or intent for this broadcast.

Optional in the API payload; omitted values default to nil. Wire name: purpose.

Returns:

  • (String, nil)


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
86
87
88
89
90
# File 'lib/inttegro/broadcast/request.rb', line 61

class Request < T::Struct
  const :request_meta, T.nilable(Inttegro::Broadcast::RequestRequestMeta), default: nil
  const :message_template, T.nilable(T.any(String, Inttegro::MessageTemplate::Reference)), default: nil
  const :email, T.nilable(Inttegro::Chime::EmailMessageInput), default: nil
  const :purpose, T.nilable(String), default: nil
  const :recipients, T::Array[T.any(Inttegro::Chime::PhoneRecipient, Inttegro::Chime::EmailRecipient, Inttegro::Chime::SavedCustomerRecipient)]
  const :sender, T.nilable(String), default: nil

  extend T::Sig

  sig { params(hash: T::Hash[String, Object], strict: T::Boolean).returns(T.attached_class) }
  def self.from_hash(hash, strict = false)
    data = hash.dup
    if (recipients_value = data["recipients"]).is_a?(Array)
      data["recipients"] = recipients_value.map do |item|
        next item unless item.is_a?(Hash)
        if item.key?("phone")
          Inttegro::Chime::PhoneRecipient.from_hash(item)
        elsif item.key?("email")
          Inttegro::Chime::EmailRecipient.from_hash(item)
        elsif item.key?("customer_id")
          Inttegro::Chime::SavedCustomerRecipient.from_hash(item)
        else
          item
        end
      end
    end
    super(data, strict)
  end
end

#recipients ⇒ Array<Inttegro::Chime::PhoneRecipient, Inttegro::Chime::EmailRecipient, Inttegro::Chime::SavedCustomerRecipient> (readonly)

Recipient objects for this broadcast. Each item must include transport and either inline contact details or customer_id.

Required in the API payload. Wire name: recipients.



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
86
87
88
89
90
# File 'lib/inttegro/broadcast/request.rb', line 61

class Request < T::Struct
  const :request_meta, T.nilable(Inttegro::Broadcast::RequestRequestMeta), default: nil
  const :message_template, T.nilable(T.any(String, Inttegro::MessageTemplate::Reference)), default: nil
  const :email, T.nilable(Inttegro::Chime::EmailMessageInput), default: nil
  const :purpose, T.nilable(String), default: nil
  const :recipients, T::Array[T.any(Inttegro::Chime::PhoneRecipient, Inttegro::Chime::EmailRecipient, Inttegro::Chime::SavedCustomerRecipient)]
  const :sender, T.nilable(String), default: nil

  extend T::Sig

  sig { params(hash: T::Hash[String, Object], strict: T::Boolean).returns(T.attached_class) }
  def self.from_hash(hash, strict = false)
    data = hash.dup
    if (recipients_value = data["recipients"]).is_a?(Array)
      data["recipients"] = recipients_value.map do |item|
        next item unless item.is_a?(Hash)
        if item.key?("phone")
          Inttegro::Chime::PhoneRecipient.from_hash(item)
        elsif item.key?("email")
          Inttegro::Chime::EmailRecipient.from_hash(item)
        elsif item.key?("customer_id")
          Inttegro::Chime::SavedCustomerRecipient.from_hash(item)
        else
          item
        end
      end
    end
    super(data, strict)
  end
end

#request_meta ⇒ Inttegro::Broadcast::RequestRequestMeta? (readonly)

Value of the request_meta field in the Inttegro API payload.

Optional in the API payload; omitted values default to nil. Wire name: request_meta.



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
86
87
88
89
90
# File 'lib/inttegro/broadcast/request.rb', line 61

class Request < T::Struct
  const :request_meta, T.nilable(Inttegro::Broadcast::RequestRequestMeta), default: nil
  const :message_template, T.nilable(T.any(String, Inttegro::MessageTemplate::Reference)), default: nil
  const :email, T.nilable(Inttegro::Chime::EmailMessageInput), default: nil
  const :purpose, T.nilable(String), default: nil
  const :recipients, T::Array[T.any(Inttegro::Chime::PhoneRecipient, Inttegro::Chime::EmailRecipient, Inttegro::Chime::SavedCustomerRecipient)]
  const :sender, T.nilable(String), default: nil

  extend T::Sig

  sig { params(hash: T::Hash[String, Object], strict: T::Boolean).returns(T.attached_class) }
  def self.from_hash(hash, strict = false)
    data = hash.dup
    if (recipients_value = data["recipients"]).is_a?(Array)
      data["recipients"] = recipients_value.map do |item|
        next item unless item.is_a?(Hash)
        if item.key?("phone")
          Inttegro::Chime::PhoneRecipient.from_hash(item)
        elsif item.key?("email")
          Inttegro::Chime::EmailRecipient.from_hash(item)
        elsif item.key?("customer_id")
          Inttegro::Chime::SavedCustomerRecipient.from_hash(item)
        else
          item
        end
      end
    end
    super(data, strict)
  end
end

#sender ⇒ String? (readonly)

Sender identifier displayed to recipients.

Optional in the API payload; omitted values default to nil. Wire name: sender.

Returns:

  • (String, nil)


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
86
87
88
89
90
# File 'lib/inttegro/broadcast/request.rb', line 61

class Request < T::Struct
  const :request_meta, T.nilable(Inttegro::Broadcast::RequestRequestMeta), default: nil
  const :message_template, T.nilable(T.any(String, Inttegro::MessageTemplate::Reference)), default: nil
  const :email, T.nilable(Inttegro::Chime::EmailMessageInput), default: nil
  const :purpose, T.nilable(String), default: nil
  const :recipients, T::Array[T.any(Inttegro::Chime::PhoneRecipient, Inttegro::Chime::EmailRecipient, Inttegro::Chime::SavedCustomerRecipient)]
  const :sender, T.nilable(String), default: nil

  extend T::Sig

  sig { params(hash: T::Hash[String, Object], strict: T::Boolean).returns(T.attached_class) }
  def self.from_hash(hash, strict = false)
    data = hash.dup
    if (recipients_value = data["recipients"]).is_a?(Array)
      data["recipients"] = recipients_value.map do |item|
        next item unless item.is_a?(Hash)
        if item.key?("phone")
          Inttegro::Chime::PhoneRecipient.from_hash(item)
        elsif item.key?("email")
          Inttegro::Chime::EmailRecipient.from_hash(item)
        elsif item.key?("customer_id")
          Inttegro::Chime::SavedCustomerRecipient.from_hash(item)
        else
          item
        end
      end
    end
    super(data, strict)
  end
end

Class Method Details

.from_hash(hash, strict = false) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/inttegro/broadcast/request.rb', line 72

def self.from_hash(hash, strict = false)
  data = hash.dup
  if (recipients_value = data["recipients"]).is_a?(Array)
    data["recipients"] = recipients_value.map do |item|
      next item unless item.is_a?(Hash)
      if item.key?("phone")
        Inttegro::Chime::PhoneRecipient.from_hash(item)
      elsif item.key?("email")
        Inttegro::Chime::EmailRecipient.from_hash(item)
      elsif item.key?("customer_id")
        Inttegro::Chime::SavedCustomerRecipient.from_hash(item)
      else
        item
      end
    end
  end
  super(data, strict)
end