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, CatalogItemDeleted, CatalogItemUpserted, CatalogUpserted, EventUndefinedType, ExperienceDeleted, ExperienceUpserted, HarmonizedItemDeleted, HarmonizedItemUpserted, Hs10CodeDeleted, Hs10CodeUpserted, Hs6CodeDeleted, Hs6CodeUpserted, ItemMarginDeleted, ItemMarginUpserted, ItemOriginDeleted, ItemOriginUpserted, ItemSalesMarginDeleted, ItemSalesMarginUpserted, LabelFormatDeleted, LabelFormatUpserted, LabelUpserted, LocalItemDeleted, LocalItemUpserted, LocalizedItemDeleted, LocalizedItemDeletedV2, LocalizedItemSnapshot, LocalizedItemUpserted, LocalizedItemUpsertedV2, MembershipDeleted, MembershipUpserted, NotificationDeleted, NotificationUpserted, OnlineAuthorizationUpserted, OnlineAuthorizationUpsertedV2, OrderDeleted, OrderIdentifierDeleted, OrderIdentifierUpserted, OrderUpserted, OrganizationCountriesPublished, OrganizationDeleted, OrganizationRatesPublished, OrganizationUpserted, PaymentDeleted, PaymentUpserted, PricingDeleted, PricingUpserted, RateDeleted, RateUpserted, RefundUpserted, RefundUpsertedV2, ReturnDeleted, ReturnUpserted, 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



5169
5170
5171
5172
5173
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5169

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.



5167
5168
5169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5167

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5183

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::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::LOCAL_ITEM_UPSERTED; LocalItemUpserted.new(hash)
    when Types::LOCAL_ITEM_DELETED; LocalItemDeleted.new(hash)
    when Types::LOCALIZED_ITEM_UPSERTED; LocalizedItemUpserted.new(hash)
    when Types::LOCALIZED_ITEM_UPSERTED_V2; LocalizedItemUpsertedV2.new(hash)
    when Types::LOCALIZED_ITEM_DELETED; LocalizedItemDeleted.new(hash)
    when Types::LOCALIZED_ITEM_DELETED_V2; LocalizedItemDeletedV2.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::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::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



5175
5176
5177
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5175

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, snapshot_upserted, snapshot_deleted, label_upserted, notification_upserted, notification_deleted, local_item_upserted, local_item_deleted, localized_item_upserted, localized_item_upserted_v2, localized_item_deleted, localized_item_deleted_v2, localized_item_snapshot, 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, organization_rates_published, organization_countries_published, return_upserted, return_deleted, targeting_item_upserted, targeting_item_deleted, tracking_label_event_upserted'
end

#to_hashObject



5179
5180
5181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5179

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