flowcommerce 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/clients/flow_catalog_v0_client.rb +499 -53
- data/lib/clients/flow_common_v0_client.rb +389 -74
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4534c623d5e0b6765aa85c03c1e82773ab0f471a
|
4
|
+
data.tar.gz: 8e715ca802435c606f7a18be56f238cc342139ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7afe47b4f026eee387da01e6c2b854c6c596a509577dc2a7d1afba60654c75e0e95cf4a863ae3446de94dd4fd42de3104cafbc58b3df47f5fa654bc57341cf7
|
7
|
+
data.tar.gz: d5c927ce2bf625ae1fda995469630d7317d3e7d962afa6e0cb12d3c491077663782b43684a5ef19ea59d54ce367ea5b625230543429ad2316d9ed412e6b5effd
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Generated by apidoc - http://www.apidoc.me
|
2
|
-
# Service version: 0.0.
|
3
|
-
# apidoc:0.11.
|
2
|
+
# Service version: 0.0.19
|
3
|
+
# apidoc:0.11.27 http://www.apidoc.me/flow/catalog/0.0.19/ruby_client
|
4
4
|
|
5
5
|
require 'cgi'
|
6
6
|
require 'net/http'
|
@@ -13,6 +13,8 @@ require 'rubygems'
|
|
13
13
|
require 'json'
|
14
14
|
require 'bigdecimal'
|
15
15
|
|
16
|
+
# API to the product catalog, defining the master catalog and all of the
|
17
|
+
# subcatalogs used to target specific subsets of the inventory to experiences.
|
16
18
|
module Io
|
17
19
|
module Flow
|
18
20
|
module Catalog
|
@@ -24,8 +26,8 @@ module Io
|
|
24
26
|
|
25
27
|
BASE_URL = 'https://catalog.api.flow.io' unless defined?(Constants::BASE_URL)
|
26
28
|
NAMESPACE = 'io.flow.catalog.v0' unless defined?(Constants::NAMESPACE)
|
27
|
-
USER_AGENT = 'apidoc:0.11.
|
28
|
-
VERSION = '0.0.
|
29
|
+
USER_AGENT = 'apidoc:0.11.27 http://www.apidoc.me/flow/catalog/0.0.19/ruby_client' unless defined?(Constants::USER_AGENT)
|
30
|
+
VERSION = '0.0.19' unless defined?(Constants::VERSION)
|
29
31
|
VERSION_MAJOR = 0 unless defined?(VERSION_MAJOR)
|
30
32
|
|
31
33
|
end
|
@@ -64,8 +66,8 @@ module Io
|
|
64
66
|
@catalogs ||= ::Io::Flow::Catalog::V0::Clients::Catalogs.new(self)
|
65
67
|
end
|
66
68
|
|
67
|
-
def
|
68
|
-
@
|
69
|
+
def functions
|
70
|
+
@functions ||= ::Io::Flow::Catalog::V0::Clients::Functions.new(self)
|
69
71
|
end
|
70
72
|
|
71
73
|
def items
|
@@ -98,15 +100,84 @@ module Io
|
|
98
100
|
|
99
101
|
end
|
100
102
|
|
101
|
-
class
|
103
|
+
class Functions
|
102
104
|
|
103
105
|
def initialize(client)
|
104
106
|
@client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::Catalog::V0::Client)
|
105
107
|
end
|
106
108
|
|
107
|
-
|
108
|
-
|
109
|
-
::
|
109
|
+
# Provides visibility into recent changes of each object, including deletion
|
110
|
+
def get_versions(organization, incoming={})
|
111
|
+
HttpClient::Preconditions.assert_class('organization', organization, String)
|
112
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
113
|
+
query = {
|
114
|
+
:id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
|
115
|
+
:name => (x = opts.delete(:name); x.nil? ? nil : HttpClient::Preconditions.assert_class('name', x, Array).map { |v| HttpClient::Preconditions.assert_class('name', v, String) }),
|
116
|
+
:limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
|
117
|
+
:offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
|
118
|
+
:sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "journal_timestamp" : x), String)
|
119
|
+
}.delete_if { |k, v| v.nil? }
|
120
|
+
r = @client.request("/#{CGI.escape(organization)}/functions/versions").with_query(query).get
|
121
|
+
r.map { |x| ::Io::Flow::Catalog::V0::Models::FunctionVersion.new(x) }
|
122
|
+
end
|
123
|
+
|
124
|
+
# Search functions. Always paginated.
|
125
|
+
def get(organization, incoming={})
|
126
|
+
HttpClient::Preconditions.assert_class('organization', organization, String)
|
127
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
128
|
+
query = {
|
129
|
+
:id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
|
130
|
+
:name => (x = opts.delete(:name); x.nil? ? nil : HttpClient::Preconditions.assert_class('name', x, Array).map { |v| HttpClient::Preconditions.assert_class('name', v, String) }),
|
131
|
+
:position => (x = opts.delete(:position); x.nil? ? nil : HttpClient::Preconditions.assert_class('position', x, Array).map { |v| HttpClient::Preconditions.assert_class('position', v, Integer) }),
|
132
|
+
:limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
|
133
|
+
:offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
|
134
|
+
:sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "lower(name)" : x), String)
|
135
|
+
}.delete_if { |k, v| v.nil? }
|
136
|
+
r = @client.request("/#{CGI.escape(organization)}/functions").with_query(query).get
|
137
|
+
r.map { |x| ::Io::Flow::Catalog::V0::Models::Function.new(x) }
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns information about a specific function.
|
141
|
+
def get_by_id(organization, id)
|
142
|
+
HttpClient::Preconditions.assert_class('organization', organization, String)
|
143
|
+
HttpClient::Preconditions.assert_class('id', id, String)
|
144
|
+
r = @client.request("/#{CGI.escape(organization)}/functions/#{CGI.escape(id)}").get
|
145
|
+
::Io::Flow::Catalog::V0::Models::Function.new(r)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Add function
|
149
|
+
def post(organization, function_form)
|
150
|
+
HttpClient::Preconditions.assert_class('organization', organization, String)
|
151
|
+
HttpClient::Preconditions.assert_class('function_form', function_form, ::Io::Flow::Catalog::V0::Models::FunctionForm)
|
152
|
+
r = @client.request("/#{CGI.escape(organization)}/functions").with_json(function_form.to_json).post
|
153
|
+
::Io::Flow::Catalog::V0::Models::Function.new(r)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Update function with the specified id, creating if it does not exist.
|
157
|
+
def put_by_id(organization, id, function_form)
|
158
|
+
HttpClient::Preconditions.assert_class('organization', organization, String)
|
159
|
+
HttpClient::Preconditions.assert_class('id', id, String)
|
160
|
+
HttpClient::Preconditions.assert_class('function_form', function_form, ::Io::Flow::Catalog::V0::Models::FunctionForm)
|
161
|
+
r = @client.request("/#{CGI.escape(organization)}/functions/#{CGI.escape(id)}").with_json(function_form.to_json).put
|
162
|
+
::Io::Flow::Catalog::V0::Models::Function.new(r)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Delete the function with this id
|
166
|
+
def delete_by_id(organization, id)
|
167
|
+
HttpClient::Preconditions.assert_class('organization', organization, String)
|
168
|
+
HttpClient::Preconditions.assert_class('id', id, String)
|
169
|
+
r = @client.request("/#{CGI.escape(organization)}/functions/#{CGI.escape(id)}").delete
|
170
|
+
nil
|
171
|
+
end
|
172
|
+
|
173
|
+
# Sync functions
|
174
|
+
def post_events_by_id_and_event(organization, id, event, hash)
|
175
|
+
HttpClient::Preconditions.assert_class('organization', organization, String)
|
176
|
+
HttpClient::Preconditions.assert_class('id', id, String)
|
177
|
+
HttpClient::Preconditions.assert_class('event', event, String)
|
178
|
+
HttpClient::Preconditions.assert_class('hash', hash, Hash)
|
179
|
+
r = @client.request("/#{CGI.escape(organization)}/functions/#{CGI.escape(id)}/events/#{CGI.escape(event)}").with_json(hash.to_json).post
|
180
|
+
nil
|
110
181
|
end
|
111
182
|
|
112
183
|
end
|
@@ -361,6 +432,60 @@ module Io
|
|
361
432
|
|
362
433
|
module Models
|
363
434
|
|
435
|
+
# A function can be represented with just it's ID, or the entire model
|
436
|
+
class ExpandableFunction
|
437
|
+
|
438
|
+
module Types
|
439
|
+
FUNCTION = 'function' unless defined?(FUNCTION)
|
440
|
+
FUNCTION_REFERENCE = 'function_reference' unless defined?(FUNCTION_REFERENCE)
|
441
|
+
end
|
442
|
+
|
443
|
+
def initialize(incoming={})
|
444
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
445
|
+
HttpClient::Preconditions.require_keys(opts, [:name], 'ExpandableFunction')
|
446
|
+
@name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
|
447
|
+
end
|
448
|
+
|
449
|
+
def to_hash
|
450
|
+
subtype_to_hash.merge(:discriminator => @name)
|
451
|
+
end
|
452
|
+
|
453
|
+
def ExpandableFunction.from_json(hash)
|
454
|
+
HttpClient::Preconditions.assert_class('hash', hash, Hash)
|
455
|
+
case HttpClient::Helper.symbolize_keys(hash)[:discriminator]
|
456
|
+
when Types::FUNCTION; Function.new(hash)
|
457
|
+
when Types::FUNCTION_REFERENCE; FunctionReference.new(hash)
|
458
|
+
else ExpandableFunctionUndefinedType.new(:name => union_type_name)
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
end
|
463
|
+
|
464
|
+
class ExpandableFunctionUndefinedType < ExpandableFunction
|
465
|
+
|
466
|
+
attr_reader :name
|
467
|
+
|
468
|
+
def initialize(incoming={})
|
469
|
+
super(:name => 'undefined_type')
|
470
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
471
|
+
@name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
|
472
|
+
end
|
473
|
+
|
474
|
+
def subtype_to_hash
|
475
|
+
raise 'Unable to serialize undefined type to json'
|
476
|
+
end
|
477
|
+
|
478
|
+
def copy(incoming={})
|
479
|
+
raise 'Operation not supported for undefined type'
|
480
|
+
end
|
481
|
+
|
482
|
+
def to_hash
|
483
|
+
raise 'Operation not supported for undefined type'
|
484
|
+
end
|
485
|
+
|
486
|
+
end
|
487
|
+
|
488
|
+
# A subcatalog can be represented with just it's ID, or the entire model
|
364
489
|
class ExpandableSubcatalog
|
365
490
|
|
366
491
|
module Types
|
@@ -413,7 +538,7 @@ module Io
|
|
413
538
|
|
414
539
|
end
|
415
540
|
|
416
|
-
class
|
541
|
+
class AdjustmentType
|
417
542
|
|
418
543
|
attr_reader :value
|
419
544
|
|
@@ -421,34 +546,125 @@ module Io
|
|
421
546
|
@value = HttpClient::Preconditions.assert_class('value', value, String)
|
422
547
|
end
|
423
548
|
|
424
|
-
# Returns the instance of
|
425
|
-
def
|
426
|
-
if value.instance_of?(
|
549
|
+
# Returns the instance of AdjustmentType for this value, creating a new instance for an unknown value
|
550
|
+
def AdjustmentType.apply(value)
|
551
|
+
if value.instance_of?(AdjustmentType)
|
427
552
|
value
|
428
553
|
else
|
429
554
|
HttpClient::Preconditions.assert_class_or_nil('value', value, String)
|
430
|
-
value.nil? ? nil : (from_string(value) ||
|
555
|
+
value.nil? ? nil : (from_string(value) || AdjustmentType.new(value))
|
431
556
|
end
|
432
557
|
end
|
433
558
|
|
434
|
-
# Returns the instance of
|
435
|
-
def
|
559
|
+
# Returns the instance of AdjustmentType for this value, or nil if not found
|
560
|
+
def AdjustmentType.from_string(value)
|
436
561
|
HttpClient::Preconditions.assert_class('value', value, String)
|
437
|
-
|
562
|
+
AdjustmentType.ALL.find { |v| v.value == value }
|
563
|
+
end
|
564
|
+
|
565
|
+
def AdjustmentType.ALL
|
566
|
+
@@all ||= [AdjustmentType.fixed_margin, AdjustmentType.percent_margin, AdjustmentType.round]
|
438
567
|
end
|
439
568
|
|
440
|
-
def
|
441
|
-
@@
|
569
|
+
def AdjustmentType.fixed_margin
|
570
|
+
@@_fixed_margin ||= AdjustmentType.new('fixed_margin')
|
442
571
|
end
|
443
572
|
|
444
|
-
|
445
|
-
|
446
|
-
@@_product ||= DimensionType.new('product')
|
573
|
+
def AdjustmentType.percent_margin
|
574
|
+
@@_percent_margin ||= AdjustmentType.new('percent_margin')
|
447
575
|
end
|
448
576
|
|
449
|
-
|
450
|
-
|
451
|
-
|
577
|
+
def AdjustmentType.round
|
578
|
+
@@_round ||= AdjustmentType.new('round')
|
579
|
+
end
|
580
|
+
|
581
|
+
def to_hash
|
582
|
+
value
|
583
|
+
end
|
584
|
+
|
585
|
+
end
|
586
|
+
|
587
|
+
class DeliveredDuty
|
588
|
+
|
589
|
+
attr_reader :value
|
590
|
+
|
591
|
+
def initialize(value)
|
592
|
+
@value = HttpClient::Preconditions.assert_class('value', value, String)
|
593
|
+
end
|
594
|
+
|
595
|
+
# Returns the instance of DeliveredDuty for this value, creating a new instance for an unknown value
|
596
|
+
def DeliveredDuty.apply(value)
|
597
|
+
if value.instance_of?(DeliveredDuty)
|
598
|
+
value
|
599
|
+
else
|
600
|
+
HttpClient::Preconditions.assert_class_or_nil('value', value, String)
|
601
|
+
value.nil? ? nil : (from_string(value) || DeliveredDuty.new(value))
|
602
|
+
end
|
603
|
+
end
|
604
|
+
|
605
|
+
# Returns the instance of DeliveredDuty for this value, or nil if not found
|
606
|
+
def DeliveredDuty.from_string(value)
|
607
|
+
HttpClient::Preconditions.assert_class('value', value, String)
|
608
|
+
DeliveredDuty.ALL.find { |v| v.value == value }
|
609
|
+
end
|
610
|
+
|
611
|
+
def DeliveredDuty.ALL
|
612
|
+
@@all ||= [DeliveredDuty.paid, DeliveredDuty.unpaid]
|
613
|
+
end
|
614
|
+
|
615
|
+
def DeliveredDuty.paid
|
616
|
+
@@_paid ||= DeliveredDuty.new('paid')
|
617
|
+
end
|
618
|
+
|
619
|
+
def DeliveredDuty.unpaid
|
620
|
+
@@_unpaid ||= DeliveredDuty.new('unpaid')
|
621
|
+
end
|
622
|
+
|
623
|
+
def to_hash
|
624
|
+
value
|
625
|
+
end
|
626
|
+
|
627
|
+
end
|
628
|
+
|
629
|
+
class Levy
|
630
|
+
|
631
|
+
attr_reader :value
|
632
|
+
|
633
|
+
def initialize(value)
|
634
|
+
@value = HttpClient::Preconditions.assert_class('value', value, String)
|
635
|
+
end
|
636
|
+
|
637
|
+
# Returns the instance of Levy for this value, creating a new instance for an unknown value
|
638
|
+
def Levy.apply(value)
|
639
|
+
if value.instance_of?(Levy)
|
640
|
+
value
|
641
|
+
else
|
642
|
+
HttpClient::Preconditions.assert_class_or_nil('value', value, String)
|
643
|
+
value.nil? ? nil : (from_string(value) || Levy.new(value))
|
644
|
+
end
|
645
|
+
end
|
646
|
+
|
647
|
+
# Returns the instance of Levy for this value, or nil if not found
|
648
|
+
def Levy.from_string(value)
|
649
|
+
HttpClient::Preconditions.assert_class('value', value, String)
|
650
|
+
Levy.ALL.find { |v| v.value == value }
|
651
|
+
end
|
652
|
+
|
653
|
+
def Levy.ALL
|
654
|
+
@@all ||= [Levy.duty, Levy.shipping, Levy.vat]
|
655
|
+
end
|
656
|
+
|
657
|
+
def Levy.duty
|
658
|
+
@@_duty ||= Levy.new('duty')
|
659
|
+
end
|
660
|
+
|
661
|
+
def Levy.shipping
|
662
|
+
@@_shipping ||= Levy.new('shipping')
|
663
|
+
end
|
664
|
+
|
665
|
+
# Value-Added Tax
|
666
|
+
def Levy.vat
|
667
|
+
@@_vat ||= Levy.new('vat')
|
452
668
|
end
|
453
669
|
|
454
670
|
def to_hash
|
@@ -504,6 +720,34 @@ module Io
|
|
504
720
|
|
505
721
|
end
|
506
722
|
|
723
|
+
class Adjustment
|
724
|
+
|
725
|
+
attr_reader :name, :value
|
726
|
+
|
727
|
+
def initialize(incoming={})
|
728
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
729
|
+
HttpClient::Preconditions.require_keys(opts, [:name, :value], 'Adjustment')
|
730
|
+
@name = (x = opts.delete(:name); x.is_a?(::Io::Flow::Catalog::V0::Models::AdjustmentType) ? x : ::Io::Flow::Catalog::V0::Models::AdjustmentType.apply(x))
|
731
|
+
@value = HttpClient::Preconditions.assert_class('value', opts.delete(:value), Numeric)
|
732
|
+
end
|
733
|
+
|
734
|
+
def to_json
|
735
|
+
JSON.dump(to_hash)
|
736
|
+
end
|
737
|
+
|
738
|
+
def copy(incoming={})
|
739
|
+
Adjustment.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
740
|
+
end
|
741
|
+
|
742
|
+
def to_hash
|
743
|
+
{
|
744
|
+
:name => name.value,
|
745
|
+
:value => value
|
746
|
+
}
|
747
|
+
end
|
748
|
+
|
749
|
+
end
|
750
|
+
|
507
751
|
class Attribute
|
508
752
|
|
509
753
|
attr_reader :key, :value
|
@@ -590,18 +834,150 @@ module Io
|
|
590
834
|
|
591
835
|
end
|
592
836
|
|
593
|
-
|
837
|
+
# Flow internal model containing an item's origin and classified harmonization
|
838
|
+
# code (6 digit)
|
839
|
+
class Flow
|
840
|
+
|
841
|
+
attr_reader :origin, :function, :hs6
|
842
|
+
|
843
|
+
def initialize(incoming={})
|
844
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
845
|
+
@origin = (x = opts.delete(:origin); x.nil? ? nil : HttpClient::Preconditions.assert_class('origin', x, String))
|
846
|
+
@function = (x = opts.delete(:function); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Catalog::V0::Models::ExpandableFunction) ? x : ::Io::Flow::Catalog::V0::Models::ExpandableFunction.from_json(x)))
|
847
|
+
@hs6 = (x = opts.delete(:hs6); x.nil? ? nil : HttpClient::Preconditions.assert_class('hs6', x, String))
|
848
|
+
end
|
849
|
+
|
850
|
+
def to_json
|
851
|
+
JSON.dump(to_hash)
|
852
|
+
end
|
853
|
+
|
854
|
+
def copy(incoming={})
|
855
|
+
Flow.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
856
|
+
end
|
857
|
+
|
858
|
+
def to_hash
|
859
|
+
{
|
860
|
+
:origin => origin,
|
861
|
+
:function => function.nil? ? nil : function.to_hash,
|
862
|
+
:hs6 => hs6
|
863
|
+
}
|
864
|
+
end
|
865
|
+
|
866
|
+
end
|
867
|
+
|
868
|
+
# Prioritized calculation yielding a localized price (also allows for custom
|
869
|
+
# defined price function)
|
870
|
+
class Function < ExpandableFunction
|
871
|
+
|
872
|
+
attr_reader :id, :subcatalog_id, :name, :position, :presets, :code, :q
|
873
|
+
|
874
|
+
def initialize(incoming={})
|
875
|
+
super(:name => ExpandableFunction::Types::FUNCTION)
|
876
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
877
|
+
HttpClient::Preconditions.require_keys(opts, [:id, :subcatalog_id, :name, :position, :presets, :code], 'Function')
|
878
|
+
@id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
|
879
|
+
@subcatalog_id = HttpClient::Preconditions.assert_class('subcatalog_id', opts.delete(:subcatalog_id), String)
|
880
|
+
@name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
|
881
|
+
@position = HttpClient::Preconditions.assert_class('position', opts.delete(:position), Integer)
|
882
|
+
@presets = (x = opts.delete(:presets); x.is_a?(::Io::Flow::Catalog::V0::Models::Presets) ? x : ::Io::Flow::Catalog::V0::Models::Presets.new(x))
|
883
|
+
@code = HttpClient::Preconditions.assert_class('code', opts.delete(:code), String)
|
884
|
+
@q = (x = opts.delete(:q); x.nil? ? nil : HttpClient::Preconditions.assert_class('q', x, String))
|
885
|
+
end
|
886
|
+
|
887
|
+
def to_json
|
888
|
+
JSON.dump(to_hash)
|
889
|
+
end
|
890
|
+
|
891
|
+
def copy(incoming={})
|
892
|
+
Function.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
893
|
+
end
|
894
|
+
|
895
|
+
def subtype_to_hash
|
896
|
+
{
|
897
|
+
:id => id,
|
898
|
+
:subcatalog_id => subcatalog_id,
|
899
|
+
:name => name,
|
900
|
+
:position => position,
|
901
|
+
:presets => presets.to_hash,
|
902
|
+
:code => code,
|
903
|
+
:q => q
|
904
|
+
}
|
905
|
+
end
|
906
|
+
|
907
|
+
end
|
908
|
+
|
909
|
+
class FunctionForm
|
910
|
+
|
911
|
+
attr_reader :name, :subcatalog_id, :q, :presets, :code, :position
|
912
|
+
|
913
|
+
def initialize(incoming={})
|
914
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
915
|
+
HttpClient::Preconditions.require_keys(opts, [:name, :subcatalog_id], 'FunctionForm')
|
916
|
+
@name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
|
917
|
+
@subcatalog_id = HttpClient::Preconditions.assert_class('subcatalog_id', opts.delete(:subcatalog_id), String)
|
918
|
+
@q = (x = opts.delete(:q); x.nil? ? nil : HttpClient::Preconditions.assert_class('q', x, String))
|
919
|
+
@presets = (x = opts.delete(:presets); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Catalog::V0::Models::Presets) ? x : ::Io::Flow::Catalog::V0::Models::Presets.new(x)))
|
920
|
+
@code = (x = opts.delete(:code); x.nil? ? nil : HttpClient::Preconditions.assert_class('code', x, String))
|
921
|
+
@position = (x = opts.delete(:position); x.nil? ? nil : HttpClient::Preconditions.assert_class('position', x, Integer))
|
922
|
+
end
|
923
|
+
|
924
|
+
def to_json
|
925
|
+
JSON.dump(to_hash)
|
926
|
+
end
|
927
|
+
|
928
|
+
def copy(incoming={})
|
929
|
+
FunctionForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
930
|
+
end
|
931
|
+
|
932
|
+
def to_hash
|
933
|
+
{
|
934
|
+
:name => name,
|
935
|
+
:subcatalog_id => subcatalog_id,
|
936
|
+
:q => q,
|
937
|
+
:presets => presets.nil? ? nil : presets.to_hash,
|
938
|
+
:code => code,
|
939
|
+
:position => position
|
940
|
+
}
|
941
|
+
end
|
942
|
+
|
943
|
+
end
|
944
|
+
|
945
|
+
class FunctionReference < ExpandableFunction
|
594
946
|
|
595
|
-
attr_reader :
|
947
|
+
attr_reader :id
|
948
|
+
|
949
|
+
def initialize(incoming={})
|
950
|
+
super(:name => ExpandableFunction::Types::FUNCTION_REFERENCE)
|
951
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
952
|
+
HttpClient::Preconditions.require_keys(opts, [:id], 'FunctionReference')
|
953
|
+
@id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
|
954
|
+
end
|
955
|
+
|
956
|
+
def to_json
|
957
|
+
JSON.dump(to_hash)
|
958
|
+
end
|
959
|
+
|
960
|
+
def copy(incoming={})
|
961
|
+
FunctionReference.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
962
|
+
end
|
963
|
+
|
964
|
+
def subtype_to_hash
|
965
|
+
{
|
966
|
+
:id => id
|
967
|
+
}
|
968
|
+
end
|
969
|
+
|
970
|
+
end
|
971
|
+
|
972
|
+
class FunctionSummary
|
973
|
+
|
974
|
+
attr_reader :id, :name
|
596
975
|
|
597
976
|
def initialize(incoming={})
|
598
977
|
opts = HttpClient::Helper.symbolize_keys(incoming)
|
599
|
-
HttpClient::Preconditions.require_keys(opts, [:
|
600
|
-
@
|
601
|
-
@
|
602
|
-
@length = (x = opts.delete(:length); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Common::V0::Models::Measurement) ? x : ::Io::Flow::Common::V0::Models::Measurement.new(x)))
|
603
|
-
@weight = (x = opts.delete(:weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Common::V0::Models::Measurement) ? x : ::Io::Flow::Common::V0::Models::Measurement.new(x)))
|
604
|
-
@width = (x = opts.delete(:width); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Common::V0::Models::Measurement) ? x : ::Io::Flow::Common::V0::Models::Measurement.new(x)))
|
978
|
+
HttpClient::Preconditions.require_keys(opts, [:id, :name], 'FunctionSummary')
|
979
|
+
@id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
|
980
|
+
@name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
|
605
981
|
end
|
606
982
|
|
607
983
|
def to_json
|
@@ -609,16 +985,45 @@ module Io
|
|
609
985
|
end
|
610
986
|
|
611
987
|
def copy(incoming={})
|
612
|
-
|
988
|
+
FunctionSummary.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
613
989
|
end
|
614
990
|
|
615
991
|
def to_hash
|
616
992
|
{
|
993
|
+
:id => id,
|
994
|
+
:name => name
|
995
|
+
}
|
996
|
+
end
|
997
|
+
|
998
|
+
end
|
999
|
+
|
1000
|
+
class FunctionVersion
|
1001
|
+
|
1002
|
+
attr_reader :id, :timestamp, :type, :function
|
1003
|
+
|
1004
|
+
def initialize(incoming={})
|
1005
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
1006
|
+
HttpClient::Preconditions.require_keys(opts, [:id, :timestamp, :type, :function], 'FunctionVersion')
|
1007
|
+
@id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
|
1008
|
+
@timestamp = HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(opts.delete(:timestamp)), DateTime)
|
1009
|
+
@type = (x = opts.delete(:type); x.is_a?(::Io::Flow::Common::V0::Models::ChangeType) ? x : ::Io::Flow::Common::V0::Models::ChangeType.apply(x))
|
1010
|
+
@function = (x = opts.delete(:function); x.is_a?(::Io::Flow::Catalog::V0::Models::Function) ? x : ::Io::Flow::Catalog::V0::Models::Function.new(x))
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
def to_json
|
1014
|
+
JSON.dump(to_hash)
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
def copy(incoming={})
|
1018
|
+
FunctionVersion.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
def to_hash
|
1022
|
+
{
|
1023
|
+
:id => id,
|
1024
|
+
:timestamp => timestamp,
|
617
1025
|
:type => type.value,
|
618
|
-
:
|
619
|
-
:length => length.nil? ? nil : length.to_hash,
|
620
|
-
:weight => weight.nil? ? nil : weight.to_hash,
|
621
|
-
:width => width.nil? ? nil : width.to_hash
|
1026
|
+
:function => function.to_hash
|
622
1027
|
}
|
623
1028
|
end
|
624
1029
|
|
@@ -652,9 +1057,11 @@ module Io
|
|
652
1057
|
|
653
1058
|
end
|
654
1059
|
|
1060
|
+
# The Flow item defines a specific item that can be purchased by a consumer. For
|
1061
|
+
# many clients, this will map to a Sku.
|
655
1062
|
class Item
|
656
1063
|
|
657
|
-
attr_reader :id, :number, :locale, :name, :currency, :price, :categories, :description, :dimensions, :images, :
|
1064
|
+
attr_reader :id, :number, :locale, :name, :currency, :price, :categories, :description, :attributes, :dimensions, :images, :flow, :local
|
658
1065
|
|
659
1066
|
def initialize(incoming={})
|
660
1067
|
opts = HttpClient::Helper.symbolize_keys(incoming)
|
@@ -667,9 +1074,10 @@ module Io
|
|
667
1074
|
@price = (x = opts.delete(:price); x.is_a?(::Io::Flow::Catalog::V0::Models::Price) ? x : ::Io::Flow::Catalog::V0::Models::Price.new(x))
|
668
1075
|
@categories = HttpClient::Preconditions.assert_class('categories', (x = opts.delete(:categories); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('categories', v, String) }
|
669
1076
|
@description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
|
670
|
-
@dimensions = HttpClient::Preconditions.assert_class('dimensions', (x = opts.delete(:dimensions); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Dimension) ? x : ::Io::Flow::Catalog::V0::Models::Dimension.new(x)) }
|
671
|
-
@images = HttpClient::Preconditions.assert_class('images', (x = opts.delete(:images); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Image) ? x : ::Io::Flow::Catalog::V0::Models::Image.new(x)) }
|
672
1077
|
@attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Attribute) ? x : ::Io::Flow::Catalog::V0::Models::Attribute.new(x)) }
|
1078
|
+
@dimensions = HttpClient::Preconditions.assert_class('dimensions', (x = opts.delete(:dimensions); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::Common::V0::Models::Dimension) ? x : ::Io::Flow::Common::V0::Models::Dimension.new(x)) }
|
1079
|
+
@images = HttpClient::Preconditions.assert_class('images', (x = opts.delete(:images); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Image) ? x : ::Io::Flow::Catalog::V0::Models::Image.new(x)) }
|
1080
|
+
@flow = (x = opts.delete(:flow); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Catalog::V0::Models::Flow) ? x : ::Io::Flow::Catalog::V0::Models::Flow.new(x)))
|
673
1081
|
@local = (x = opts.delete(:local); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Catalog::V0::Models::Local) ? x : ::Io::Flow::Catalog::V0::Models::Local.new(x)))
|
674
1082
|
end
|
675
1083
|
|
@@ -691,18 +1099,20 @@ module Io
|
|
691
1099
|
:price => price.to_hash,
|
692
1100
|
:categories => categories,
|
693
1101
|
:description => description,
|
1102
|
+
:attributes => attributes.map { |o| o.to_hash },
|
694
1103
|
:dimensions => dimensions.map { |o| o.to_hash },
|
695
1104
|
:images => images.map { |o| o.to_hash },
|
696
|
-
:
|
1105
|
+
:flow => flow.nil? ? nil : flow.to_hash,
|
697
1106
|
:local => local.nil? ? nil : local.to_hash
|
698
1107
|
}
|
699
1108
|
end
|
700
1109
|
|
701
1110
|
end
|
702
1111
|
|
1112
|
+
# The item form defines the data required to create an item.
|
703
1113
|
class ItemForm
|
704
1114
|
|
705
|
-
attr_reader :number, :locale, :name, :currency, :price, :categories, :description, :
|
1115
|
+
attr_reader :number, :locale, :name, :currency, :price, :categories, :description, :attributes, :dimensions, :images
|
706
1116
|
|
707
1117
|
def initialize(incoming={})
|
708
1118
|
opts = HttpClient::Helper.symbolize_keys(incoming)
|
@@ -714,9 +1124,9 @@ module Io
|
|
714
1124
|
@price = HttpClient::Preconditions.assert_class('price', opts.delete(:price), Numeric)
|
715
1125
|
@categories = (x = opts.delete(:categories); x.nil? ? nil : HttpClient::Preconditions.assert_class('categories', x, Array).map { |v| HttpClient::Preconditions.assert_class('categories', v, String) })
|
716
1126
|
@description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
|
717
|
-
@dimensions = (x = opts.delete(:dimensions); x.nil? ? nil : HttpClient::Preconditions.assert_class('dimensions', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Dimension) ? x : ::Io::Flow::Catalog::V0::Models::Dimension.new(x)) })
|
718
|
-
@images = (x = opts.delete(:images); x.nil? ? nil : HttpClient::Preconditions.assert_class('images', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Image) ? x : ::Io::Flow::Catalog::V0::Models::Image.new(x)) })
|
719
1127
|
@attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Attribute) ? x : ::Io::Flow::Catalog::V0::Models::Attribute.new(x)) })
|
1128
|
+
@dimensions = (x = opts.delete(:dimensions); x.nil? ? nil : HttpClient::Preconditions.assert_class('dimensions', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::Common::V0::Models::Dimension) ? x : ::Io::Flow::Common::V0::Models::Dimension.new(x)) })
|
1129
|
+
@images = (x = opts.delete(:images); x.nil? ? nil : HttpClient::Preconditions.assert_class('images', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Image) ? x : ::Io::Flow::Catalog::V0::Models::Image.new(x)) })
|
720
1130
|
end
|
721
1131
|
|
722
1132
|
def to_json
|
@@ -736,9 +1146,9 @@ module Io
|
|
736
1146
|
:price => price,
|
737
1147
|
:categories => categories.nil? ? nil : categories,
|
738
1148
|
:description => description,
|
1149
|
+
:attributes => attributes.nil? ? nil : attributes.map { |o| o.to_hash },
|
739
1150
|
:dimensions => dimensions.nil? ? nil : dimensions.map { |o| o.to_hash },
|
740
|
-
:images => images.nil? ? nil : images.map { |o| o.to_hash }
|
741
|
-
:attributes => attributes.nil? ? nil : attributes.map { |o| o.to_hash }
|
1151
|
+
:images => images.nil? ? nil : images.map { |o| o.to_hash }
|
742
1152
|
}
|
743
1153
|
end
|
744
1154
|
|
@@ -804,12 +1214,13 @@ module Io
|
|
804
1214
|
|
805
1215
|
class LocalizedPrice
|
806
1216
|
|
807
|
-
attr_reader :key, :amount, :label
|
1217
|
+
attr_reader :key, :currency, :amount, :label
|
808
1218
|
|
809
1219
|
def initialize(incoming={})
|
810
1220
|
opts = HttpClient::Helper.symbolize_keys(incoming)
|
811
|
-
HttpClient::Preconditions.require_keys(opts, [:key, :amount, :label], 'LocalizedPrice')
|
1221
|
+
HttpClient::Preconditions.require_keys(opts, [:key, :currency, :amount, :label], 'LocalizedPrice')
|
812
1222
|
@key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
|
1223
|
+
@currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
|
813
1224
|
@amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric)
|
814
1225
|
@label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String)
|
815
1226
|
end
|
@@ -825,6 +1236,7 @@ module Io
|
|
825
1236
|
def to_hash
|
826
1237
|
{
|
827
1238
|
:key => key,
|
1239
|
+
:currency => currency,
|
828
1240
|
:amount => amount,
|
829
1241
|
:label => label
|
830
1242
|
}
|
@@ -832,6 +1244,34 @@ module Io
|
|
832
1244
|
|
833
1245
|
end
|
834
1246
|
|
1247
|
+
# Presentation for UI that is used to generate a localized price function
|
1248
|
+
class Presets
|
1249
|
+
|
1250
|
+
attr_reader :adjustments, :levies
|
1251
|
+
|
1252
|
+
def initialize(incoming={})
|
1253
|
+
opts = HttpClient::Helper.symbolize_keys(incoming)
|
1254
|
+
@adjustments = HttpClient::Preconditions.assert_class('adjustments', (x = opts.delete(:adjustments); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Adjustment) ? x : ::Io::Flow::Catalog::V0::Models::Adjustment.new(x)) }
|
1255
|
+
@levies = HttpClient::Preconditions.assert_class('levies', (x = opts.delete(:levies); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::Catalog::V0::Models::Levy) ? x : ::Io::Flow::Catalog::V0::Models::Levy.apply(x)) }
|
1256
|
+
end
|
1257
|
+
|
1258
|
+
def to_json
|
1259
|
+
JSON.dump(to_hash)
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
def copy(incoming={})
|
1263
|
+
Presets.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
|
1264
|
+
end
|
1265
|
+
|
1266
|
+
def to_hash
|
1267
|
+
{
|
1268
|
+
:adjustments => adjustments.map { |o| o.to_hash },
|
1269
|
+
:levies => levies.map { |o| o.value }
|
1270
|
+
}
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
end
|
1274
|
+
|
835
1275
|
class Price
|
836
1276
|
|
837
1277
|
attr_reader :amount, :label
|
@@ -860,16 +1300,19 @@ module Io
|
|
860
1300
|
|
861
1301
|
end
|
862
1302
|
|
1303
|
+
# A configuration with custom query to select a subset of master catalog items
|
1304
|
+
# for a localized experience
|
863
1305
|
class Subcatalog < ExpandableSubcatalog
|
864
1306
|
|
865
|
-
attr_reader :id, :catalog, :key, :settings, :query
|
1307
|
+
attr_reader :id, :catalog, :country, :key, :settings, :query
|
866
1308
|
|
867
1309
|
def initialize(incoming={})
|
868
1310
|
super(:name => ExpandableSubcatalog::Types::SUBCATALOG)
|
869
1311
|
opts = HttpClient::Helper.symbolize_keys(incoming)
|
870
|
-
HttpClient::Preconditions.require_keys(opts, [:id, :catalog, :key, :settings], 'Subcatalog')
|
1312
|
+
HttpClient::Preconditions.require_keys(opts, [:id, :catalog, :country, :key, :settings], 'Subcatalog')
|
871
1313
|
@id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
|
872
1314
|
@catalog = (x = opts.delete(:catalog); x.is_a?(::Io::Flow::Catalog::V0::Models::Catalog) ? x : ::Io::Flow::Catalog::V0::Models::Catalog.new(x))
|
1315
|
+
@country = HttpClient::Preconditions.assert_class('country', opts.delete(:country), String)
|
873
1316
|
@key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
|
874
1317
|
@settings = (x = opts.delete(:settings); x.is_a?(::Io::Flow::Catalog::V0::Models::SubcatalogSettings) ? x : ::Io::Flow::Catalog::V0::Models::SubcatalogSettings.new(x))
|
875
1318
|
@query = (x = opts.delete(:query); x.nil? ? nil : HttpClient::Preconditions.assert_class('query', x, String))
|
@@ -887,6 +1330,7 @@ module Io
|
|
887
1330
|
{
|
888
1331
|
:id => id,
|
889
1332
|
:catalog => catalog.to_hash,
|
1333
|
+
:country => country,
|
890
1334
|
:key => key,
|
891
1335
|
:settings => settings.to_hash,
|
892
1336
|
:query => query
|
@@ -897,11 +1341,12 @@ module Io
|
|
897
1341
|
|
898
1342
|
class SubcatalogForm
|
899
1343
|
|
900
|
-
attr_reader :key, :query, :settings
|
1344
|
+
attr_reader :key, :country, :query, :settings
|
901
1345
|
|
902
1346
|
def initialize(incoming={})
|
903
1347
|
opts = HttpClient::Helper.symbolize_keys(incoming)
|
904
1348
|
@key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
|
1349
|
+
@country = (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String))
|
905
1350
|
@query = (x = opts.delete(:query); x.nil? ? nil : HttpClient::Preconditions.assert_class('query', x, String))
|
906
1351
|
@settings = (x = opts.delete(:settings); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Catalog::V0::Models::SubcatalogSettingsForm) ? x : ::Io::Flow::Catalog::V0::Models::SubcatalogSettingsForm.new(x)))
|
907
1352
|
end
|
@@ -917,6 +1362,7 @@ module Io
|
|
917
1362
|
def to_hash
|
918
1363
|
{
|
919
1364
|
:key => key,
|
1365
|
+
:country => country,
|
920
1366
|
:query => query,
|
921
1367
|
:settings => settings.nil? ? nil : settings.to_hash
|
922
1368
|
}
|