Class: MarketoAPI::MObject::Association
- Inherits:
-
Object
- Object
- MarketoAPI::MObject::Association
- Defined in:
- lib/marketo_api/mobject.rb
Overview
:nodoc:
Constant Summary collapse
- TYPES =
:nodoc:
[ #:nodoc: :Lead, :Company, :Opportunity ]
Instance Attribute Summary collapse
-
#external_key ⇒ Object
(also: #external)
readonly
Returns the value of attribute external_key.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, options = {}) ⇒ Association
constructor
A new instance of Association.
- #to_h ⇒ Object
Constructor Details
#initialize(type, options = {}) ⇒ Association
Returns a new instance of Association.
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/marketo_api/mobject.rb', line 232 def initialize(type, = {}) unless TYPES.include?(type.to_s.capitalize.to_sym) raise ArgumentError, "Invalid type #{type}" end @type = TYPES[TYPES.index(type.to_s.capitalize.to_sym)] .fetch(:id) { .fetch(:external) { .fetch(:external_key) { raise KeyError, "Must have one of :id or :external" } } } @id = [:id] @external_key = [:external] || [:external_key] end |
Instance Attribute Details
#external_key ⇒ Object (readonly) Also known as: external
Returns the value of attribute external_key.
229 230 231 |
# File 'lib/marketo_api/mobject.rb', line 229 def external_key @external_key end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
229 230 231 |
# File 'lib/marketo_api/mobject.rb', line 229 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
229 230 231 |
# File 'lib/marketo_api/mobject.rb', line 229 def type @type end |
Instance Method Details
#==(other) ⇒ Object
251 252 253 254 |
# File 'lib/marketo_api/mobject.rb', line 251 def ==(other) type.equal?(other.type) && id == other.id && external_key == other.external_key end |
#to_h ⇒ Object
256 257 258 259 260 261 262 |
# File 'lib/marketo_api/mobject.rb', line 256 def to_h { m_obj_type: type, id: id, external_key: external_key, } end |