Class: Io::Flow::V0::Models::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Event

Returns a new instance of Event.



4505
4506
4507
4508
4509
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4505

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:discriminator], 'Event')
  @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String)
end

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



4503
4504
4505
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4503

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4519

def Event.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip
  if discriminator.empty?
    raise "Union type[event] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::ATTRIBUTE_UPSERTED; AttributeUpserted.new(hash)
    when Types::ATTRIBUTE_DELETED; AttributeDeleted.new(hash)
    when Types::CATALOG_UPSERTED; CatalogUpserted.new(hash)
    when Types::CATALOG_DELETED; CatalogDeleted.new(hash)
    when Types::SUBCATALOG_UPSERTED; SubcatalogUpserted.new(hash)
    when Types::SUBCATALOG_DELETED; SubcatalogDeleted.new(hash)
    when Types::CATALOG_ITEM_UPSERTED; CatalogItemUpserted.new(hash)
    when Types::CATALOG_ITEM_DELETED; CatalogItemDeleted.new(hash)
    when Types::SUBCATALOG_ITEM_UPSERTED; SubcatalogItemUpserted.new(hash)
    when Types::SUBCATALOG_ITEM_DELETED; SubcatalogItemDeleted.new(hash)
    when Types::RATE_DELETED; RateDeleted.new(hash)
    when Types::RATE_UPSERTED; RateUpserted.new(hash)
    when Types::EXPERIENCE_DELETED; ExperienceDeleted.new(hash)
    when Types::EXPERIENCE_UPSERTED; ExperienceUpserted.new(hash)
    when Types::ITEM_MARGIN_DELETED; ItemMarginDeleted.new(hash)
    when Types::ITEM_MARGIN_UPSERTED; ItemMarginUpserted.new(hash)
    when Types::LABEL_FORMAT_DELETED; LabelFormatDeleted.new(hash)
    when Types::LABEL_FORMAT_UPSERTED; LabelFormatUpserted.new(hash)
    when Types::ORDER_DELETED; OrderDeleted.new(hash)
    when Types::ORDER_UPSERTED; OrderUpserted.new(hash)
    when Types::ORDER_IDENTIFIER_DELETED; OrderIdentifierDeleted.new(hash)
    when Types::ORDER_IDENTIFIER_UPSERTED; OrderIdentifierUpserted.new(hash)
    when Types::PRICING_DELETED; PricingDeleted.new(hash)
    when Types::PRICING_UPSERTED; PricingUpserted.new(hash)
    when Types::TIER_UPSERTED; TierUpserted.new(hash)
    when Types::TIER_DELETED; TierDeleted.new(hash)
    when Types::HS6_CODE_UPSERTED; Hs6CodeUpserted.new(hash)
    when Types::HS6_CODE_DELETED; Hs6CodeDeleted.new(hash)
    when Types::HS10_CODE_UPSERTED; Hs10CodeUpserted.new(hash)
    when Types::HS10_CODE_DELETED; Hs10CodeDeleted.new(hash)
    when Types::ITEM_ORIGIN_UPSERTED; ItemOriginUpserted.new(hash)
    when Types::ITEM_ORIGIN_DELETED; ItemOriginDeleted.new(hash)
    when Types::HARMONIZED_ITEM_UPSERTED; HarmonizedItemUpserted.new(hash)
    when Types::HARMONIZED_ITEM_DELETED; HarmonizedItemDeleted.new(hash)
    when Types::SNAPSHOT_UPSERTED; SnapshotUpserted.new(hash)
    when Types::SNAPSHOT_DELETED; SnapshotDeleted.new(hash)
    when Types::LABEL_UPSERTED; LabelUpserted.new(hash)
    when Types::NOTIFICATION_UPSERTED; NotificationUpserted.new(hash)
    when Types::NOTIFICATION_DELETED; NotificationDeleted.new(hash)
    when Types::LOCALIZED_ITEM_UPSERTED; LocalizedItemUpserted.new(hash)
    when Types::LOCALIZED_ITEM_DELETED; LocalizedItemDeleted.new(hash)
    when Types::LOCALIZED_ITEM_SNAPSHOT; LocalizedItemSnapshot.new(hash)
    when Types::MEMBERSHIP_UPSERTED; MembershipUpserted.new(hash)
    when Types::MEMBERSHIP_DELETED; MembershipDeleted.new(hash)
    when Types::ORGANIZATION_UPSERTED; OrganizationUpserted.new(hash)
    when Types::ORGANIZATION_DELETED; OrganizationDeleted.new(hash)
    when Types::AUTHORIZATION_UPSERTED; AuthorizationUpserted.new(hash)
    when Types::AUTHORIZATION_DELETED; AuthorizationDeleted.new(hash)
    when Types::CAPTURE_UPSERTED; CaptureUpserted.new(hash)
    when Types::CARD_UPSERTED; CardUpserted.new(hash)
    when Types::CARD_DELETED; CardDeleted.new(hash)
    when Types::REFUND_UPSERTED; RefundUpserted.new(hash)
    when Types::RETURN_UPSERTED; ReturnUpserted.new(hash)
    when Types::RETURN_DELETED; ReturnDeleted.new(hash)
    when Types::TARGETING_ITEM_UPSERTED; TargetingItemUpserted.new(hash)
    when Types::TARGETING_ITEM_DELETED; TargetingItemDeleted.new(hash)
    when Types::TRACKING_LABEL_EVENT_UPSERTED; TrackingLabelEventUpserted.new(hash)
    else EventUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



4511
4512
4513
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4511

def subtype_to_hash
  raise 'Cannot serialize an instance of event directly - must use one of the specific types: attribute_upserted, attribute_deleted, catalog_upserted, catalog_deleted, subcatalog_upserted, subcatalog_deleted, catalog_item_upserted, catalog_item_deleted, subcatalog_item_upserted, subcatalog_item_deleted, rate_deleted, rate_upserted, experience_deleted, experience_upserted, item_margin_deleted, item_margin_upserted, label_format_deleted, label_format_upserted, order_deleted, order_upserted, order_identifier_deleted, order_identifier_upserted, pricing_deleted, pricing_upserted, tier_upserted, tier_deleted, hs6_code_upserted, hs6_code_deleted, hs10_code_upserted, hs10_code_deleted, item_origin_upserted, item_origin_deleted, harmonized_item_upserted, harmonized_item_deleted, snapshot_upserted, snapshot_deleted, label_upserted, notification_upserted, notification_deleted, localized_item_upserted, localized_item_deleted, localized_item_snapshot, membership_upserted, membership_deleted, organization_upserted, organization_deleted, authorization_upserted, authorization_deleted, capture_upserted, card_upserted, card_deleted, refund_upserted, return_upserted, return_deleted, targeting_item_upserted, targeting_item_deleted, tracking_label_event_upserted'
end

#to_hashObject



4515
4516
4517
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4515

def to_hash
  subtype_to_hash.merge(:discriminator => @discriminator)
end