huginn_bigcommerce_product_agent 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,55 @@
1
+ module BigcommerceProductAgent
2
+ module Mapper
3
+ class VariantMapper
4
+
5
+ def self.map(variant, option_values, product_id, variant_id=nil, not_purchasable_format_list, bc_option_value)
6
+ mapped = {
7
+ product_id: product_id,
8
+ sku: variant['sku'],
9
+ price: variant['offers'] && variant['offers'][0] ? variant['offers'][0]['price'] : '0',
10
+ cost_price: nil,
11
+ sale_price: nil,
12
+ retail_price: nil,
13
+ weight: variant['weight'] ? variant['weight']['value'] : '0',
14
+ width: variant['width'] ? variant['width']['value'] : '0',
15
+ depth: variant['depth'] ? variant['depth']['value'] : '0',
16
+ height: variant['height'] ? variant['height']['value'] : '0',
17
+ is_free_shipping: false,
18
+ fixed_cost_shipping_price: nil,
19
+ purchasing_disabled: false,
20
+ purchasing_disabled_message: '',
21
+ upc: variant['isbn'] ? variant['isbn'] : variant['gtin12'],
22
+ inventory_level: nil,
23
+ inventory_warning_level: nil,
24
+ bin_picking_number: nil,
25
+ option_values: option_values,
26
+ }
27
+
28
+ if variant_id
29
+ mapped[:id] = variant_id
30
+ end
31
+
32
+ unless not_purchasable_format_list.nil?
33
+ not_purchasable_format_list.each do |format|
34
+ if format == bc_option_value['label']
35
+ mapped[:purchasing_disabled] = true
36
+ end
37
+ end
38
+ end
39
+
40
+ return mapped
41
+ end
42
+
43
+ def self.map_option_value(option_value_id, option_id)
44
+ return {
45
+ id: option_value_id,
46
+ option_id: option_id,
47
+ }
48
+ end
49
+
50
+ private
51
+
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ # require 'rails_helper'
2
+ # require 'huginn_agent/spec_helper'
3
+ #
4
+ # describe Agents::BigcommerceProductAgent do
5
+ # before(:each) do
6
+ # @valid_options = Agents::BigcommerceProductAgent.new.default_options
7
+ # @checker = Agents::BigcommerceProductAgent.new(:name => "BigcommerceProductAgent", :options => @valid_options)
8
+ # @checker.user = users(:bob)
9
+ # @checker.save!
10
+ # end
11
+ #
12
+ # pending "add specs here"
13
+ # end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: huginn_bigcommerce_product_agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.10.1
5
+ platform: ruby
6
+ authors:
7
+ - Jacob Spizziri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: huginn_agent
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Agent that takes a generic product interface and upserts that product
56
+ in BigCommerce.
57
+ email:
58
+ - jspizziri@weare5stones.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - lib/abstract_client.rb
64
+ - lib/client/custom_field.rb
65
+ - lib/client/meta_field.rb
66
+ - lib/client/modifier.rb
67
+ - lib/client/modifier_value.rb
68
+ - lib/client/product.rb
69
+ - lib/client/product_option.rb
70
+ - lib/client/product_option_value.rb
71
+ - lib/client/product_variant.rb
72
+ - lib/client/variant.rb
73
+ - lib/huginn_bigcommerce_product_agent.rb
74
+ - lib/huginn_bigcommerce_product_agent/bigcommerce_product_agent.rb
75
+ - lib/mapper/custom_field_mapper.rb
76
+ - lib/mapper/meta_field_mapper.rb
77
+ - lib/mapper/modifier_mapper.rb
78
+ - lib/mapper/option_mapper.rb
79
+ - lib/mapper/option_value_mapper.rb
80
+ - lib/mapper/product_mapper.rb
81
+ - lib/mapper/variant_mapper.rb
82
+ - spec/bigcommerce_product_agent_spec.rb
83
+ homepage: https://github.com/5-stones/huginn_bigcommerce_product_agent
84
+ licenses: []
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.0.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Agent that takes a generic product interface and upserts that product in
105
+ BigCommerce.
106
+ test_files:
107
+ - spec/bigcommerce_product_agent_spec.rb