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

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

Direct Known Subclasses

AllocationDeleted, AllocationUpserted, AttributeDeleted, AttributeUpserted, AuthorizationDeleted, AuthorizationDeletedV2, AuthorizationStatusChanged, AuthorizationUpserted, AvailablePromotionsDeleted, AvailablePromotionsUpserted, CaptureUpserted, CaptureUpsertedV2, CardAuthorizationUpserted, CardAuthorizationUpsertedV2, CardDeleted, CardUpserted, CardUpsertedV2, CatalogDeleted, CatalogItemCountryStatesPublished, CatalogItemDeleted, CatalogItemUpserted, CatalogUpserted, EventUndefinedType, ExperienceDeleted, ExperienceUpserted, HarmonizedItemDeleted, HarmonizedItemUpserted, HarmonizedLandedCostUpserted, Hs10CodeDeleted, Hs10CodeUpserted, Hs6CodeDeleted, Hs6CodeUpserted, ItemMarginDeleted, ItemMarginUpserted, ItemOriginDeleted, ItemOriginUpserted, ItemSalesMarginDeleted, ItemSalesMarginUpserted, LabelFormatDeleted, LabelFormatUpserted, LabelUpserted, LocalItemDeleted, LocalItemUpserted, ManifestedLabelDeleted, ManifestedLabelUpserted, MembershipDeleted, MembershipUpserted, NotificationDeleted, NotificationUpserted, OnlineAuthorizationUpserted, OnlineAuthorizationUpsertedV2, OrderDeleted, OrderIdentifierDeleted, OrderIdentifierUpserted, OrderUpserted, OrganizationCountriesPublished, OrganizationDeleted, OrganizationRatesPublished, OrganizationUpserted, PaymentDeleted, PaymentUpserted, PricingDeleted, PricingUpserted, RateDeleted, RateUpserted, RefundUpserted, RefundUpsertedV2, ReturnDeleted, ReturnUpserted, ReversalUpserted, SnapshotDeleted, SnapshotUpserted, SubcatalogDeleted, SubcatalogItemDeleted, SubcatalogItemUpserted, SubcatalogUpserted, TargetingItemDeleted, TargetingItemUpserted, TierDeleted, TierUpserted, TrackingLabelEventUpserted

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.



5464
5465
5466
5467
5468
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5464

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.



5462
5463
5464
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5462

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5478

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::AVAILABLE_PROMOTIONS_UPSERTED; AvailablePromotionsUpserted.new(hash)
    when Types::AVAILABLE_PROMOTIONS_DELETED; AvailablePromotionsDeleted.new(hash)
    when Types::ALLOCATION_DELETED; AllocationDeleted.new(hash)
    when Types::ALLOCATION_UPSERTED; AllocationUpserted.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::ITEM_SALES_MARGIN_DELETED; ItemSalesMarginDeleted.new(hash)
    when Types::ITEM_SALES_MARGIN_UPSERTED; ItemSalesMarginUpserted.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::HARMONIZED_LANDED_COST_UPSERTED; HarmonizedLandedCostUpserted.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::MANIFESTED_LABEL_UPSERTED; ManifestedLabelUpserted.new(hash)
    when Types::MANIFESTED_LABEL_DELETED; ManifestedLabelDeleted.new(hash)
    when Types::LOCAL_ITEM_UPSERTED; LocalItemUpserted.new(hash)
    when Types::LOCAL_ITEM_DELETED; LocalItemDeleted.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::AUTHORIZATION_DELETED_V2; AuthorizationDeletedV2.new(hash)
    when Types::AUTHORIZATION_STATUS_CHANGED; AuthorizationStatusChanged.new(hash)
    when Types::CARD_AUTHORIZATION_UPSERTED; CardAuthorizationUpserted.new(hash)
    when Types::CARD_AUTHORIZATION_UPSERTED_V2; CardAuthorizationUpsertedV2.new(hash)
    when Types::ONLINE_AUTHORIZATION_UPSERTED; OnlineAuthorizationUpserted.new(hash)
    when Types::ONLINE_AUTHORIZATION_UPSERTED_V2; OnlineAuthorizationUpsertedV2.new(hash)
    when Types::CAPTURE_UPSERTED; CaptureUpserted.new(hash)
    when Types::CAPTURE_UPSERTED_V2; CaptureUpsertedV2.new(hash)
    when Types::CARD_UPSERTED; CardUpserted.new(hash)
    when Types::CARD_UPSERTED_V2; CardUpsertedV2.new(hash)
    when Types::CARD_DELETED; CardDeleted.new(hash)
    when Types::PAYMENT_UPSERTED; PaymentUpserted.new(hash)
    when Types::PAYMENT_DELETED; PaymentDeleted.new(hash)
    when Types::REFUND_UPSERTED; RefundUpserted.new(hash)
    when Types::REFUND_UPSERTED_V2; RefundUpsertedV2.new(hash)
    when Types::REVERSAL_UPSERTED; ReversalUpserted.new(hash)
    when Types::CATALOG_ITEM_COUNTRY_STATES_PUBLISHED; CatalogItemCountryStatesPublished.new(hash)
    when Types::ORGANIZATION_RATES_PUBLISHED; OrganizationRatesPublished.new(hash)
    when Types::ORGANIZATION_COUNTRIES_PUBLISHED; OrganizationCountriesPublished.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



5470
5471
5472
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5470

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, available_promotions_upserted, available_promotions_deleted, allocation_deleted, allocation_upserted, experience_deleted, experience_upserted, item_margin_deleted, item_margin_upserted, item_sales_margin_deleted, item_sales_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, harmonized_landed_cost_upserted, snapshot_upserted, snapshot_deleted, label_upserted, notification_upserted, notification_deleted, manifested_label_upserted, manifested_label_deleted, local_item_upserted, local_item_deleted, membership_upserted, membership_deleted, organization_upserted, organization_deleted, authorization_upserted, authorization_deleted, authorization_deleted_v2, authorization_status_changed, card_authorization_upserted, card_authorization_upserted_v2, online_authorization_upserted, online_authorization_upserted_v2, capture_upserted, capture_upserted_v2, card_upserted, card_upserted_v2, card_deleted, payment_upserted, payment_deleted, refund_upserted, refund_upserted_v2, reversal_upserted, catalog_item_country_states_published, organization_rates_published, organization_countries_published, return_upserted, return_deleted, targeting_item_upserted, targeting_item_deleted, tracking_label_event_upserted'
end

#to_hashObject



5474
5475
5476
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5474

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