magento 0.24.0 → 0.25.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cc3c4705cb31c6aab0ee3e39b0513bd9e21fa7f98fa6c0564e832a01c488b68
4
- data.tar.gz: 20354ed49b5e998940775d8e3f07aea5ca0a0e2be5d482634c77528f3209e330
3
+ metadata.gz: 39351f6f0160cca4294ba7f1eb49a9d45ad4928f23c1e16a119ea15a9d35de76
4
+ data.tar.gz: 0b57db15034198ca599d545966b63aaf535675a0ba122f0056f823617395e163
5
5
  SHA512:
6
- metadata.gz: 8e927a070c8b469cc0b3019ca27c9d74c51cb270b4165e3fb2343fd3c54d406d0d33507ad2aba9a53250d4c513e70eeb3c92adea579c0b2c775e23667e4fd1c8
7
- data.tar.gz: f91fd2fcaca2777d599eac5eb665553adf5054eaa8a42593c2bad95226b953c43e14e1e7687e4c64c4351cc9f6e05fc35b3edd1e181fcd99976f481706e2d791
6
+ metadata.gz: aaa7594c1b4d21fc2585552ce9187ce33a9b4605c6809d5d735c4ea82269f5acef51ae370e43688a16cf04faf826cf990f280dc005a010329d01be2214d86341
7
+ data.tar.gz: 0f07ba186842264c655e32637c48f8fdf557e8f6c97cbe5914cbb4ed5c3657308e41dc22e379de235ed97c38cd194fb27b8c613acccf0cbbb92d1a379e31f883
data/.gitignore CHANGED
@@ -7,7 +7,6 @@
7
7
  coverage
8
8
  InstalledFiles
9
9
  lib/bundler/man
10
- pkg
11
10
  rdoc
12
11
  spec/reports
13
12
  test/tmp
@@ -25,4 +24,7 @@ test/vcr_cassettes
25
24
 
26
25
  .vscode
27
26
  .byebug_history
28
- /manual_test
27
+ /manual_test
28
+
29
+ # rspec failure tracking
30
+ .rspec_status
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add in your Gemfile
6
6
 
7
7
  ```rb
8
- gem 'magento', '~> 0.24.0'
8
+ gem 'magento', '~> 0.25.0'
9
9
  ```
10
10
 
11
11
  or run
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Magento
4
+ module Params
5
+ class CreateProductLink < Dry::Struct
6
+ LinkType = Type::String.enum(
7
+ 'related',
8
+ 'upsell',
9
+ 'crosssell',
10
+ 'associated'
11
+ )
12
+
13
+ attribute :link_type, LinkType
14
+ attribute :linked_product_sku, Type::String
15
+ attribute :linked_product_type, Magento::Params::CreateProduct::ProductTypes
16
+ attribute :position, Type::Integer
17
+ attribute :sku, Type::String
18
+
19
+ def to_h
20
+ {
21
+ link_type: link_type,
22
+ linked_product_sku: linked_product_sku,
23
+ linked_product_type: linked_product_type,
24
+ position: position,
25
+ sku: sku
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -47,7 +47,6 @@ module Magento
47
47
  self.class.remove_media(sku, media_id)
48
48
  end
49
49
 
50
- #
51
50
  # Add {price} on product {sku} for specified {customer_group_id}
52
51
  #
53
52
  # Param {quantity} is the minimun amount to apply the price
@@ -134,6 +133,14 @@ module Magento
134
133
  def update_stock(sku, id, attributes)
135
134
  request.put("products/#{sku}/stockItems/#{id}", stockItem: attributes).parse
136
135
  end
136
+
137
+ def create_links(sku, product_links)
138
+ request.post("products/#{sku}/links", { items: product_links })
139
+ end
140
+
141
+ def remove_link(sku, link_type:, linked_product_sku:)
142
+ request.delete("products/#{sku}/links/#{link_type}/#{linked_product_sku}")
143
+ end
137
144
  end
138
145
  end
139
146
  end
@@ -23,7 +23,7 @@ module Magento
23
23
  'to' # The end of a range. Must be used with from
24
24
  ].freeze
25
25
 
26
- def initialize(model, request: Request.new)
26
+ def initialize(model, request: Request.new, api_resource: nil)
27
27
  @model = model
28
28
  @request = request
29
29
  @filter_groups = nil
@@ -31,6 +31,7 @@ module Magento
31
31
  @page_size = 50
32
32
  @sort_orders = nil
33
33
  @fields = nil
34
+ @endpoint = api_resource || model.api_resource
34
35
  end
35
36
 
36
37
  def where(attributes)
@@ -131,7 +132,7 @@ module Magento
131
132
  attr_accessor :current_page, :filter_groups, :request, :sort_orders, :model, :fields
132
133
 
133
134
  def endpoint
134
- model.api_resource
135
+ @endpoint
135
136
  end
136
137
 
137
138
  def verify_id(field)
@@ -27,6 +27,10 @@ module Magento
27
27
  def generate_coupon(attributes)
28
28
  request.post('coupons/generate', attributes).parse
29
29
  end
30
+
31
+ protected def query
32
+ Query.new(self, api_resource: 'salesRules/search')
33
+ end
30
34
  end
31
35
  end
32
36
  end
@@ -1,3 +1,3 @@
1
1
  module Magento
2
- VERSION = '0.24.0'
2
+ VERSION = '0.25.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magento
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wallas Faria
@@ -89,7 +89,6 @@ files:
89
89
  - ".github/workflows/gem-push.yml"
90
90
  - ".gitignore"
91
91
  - ".rspec"
92
- - ".rspec_status"
93
92
  - Gemfile
94
93
  - README.md
95
94
  - Rakefile
@@ -118,6 +117,7 @@ files:
118
117
  - lib/magento/params/create_custom_attribute.rb
119
118
  - lib/magento/params/create_image.rb
120
119
  - lib/magento/params/create_product.rb
120
+ - lib/magento/params/create_product_link.rb
121
121
  - lib/magento/polymorphic_model.rb
122
122
  - lib/magento/product.rb
123
123
  - lib/magento/query.rb
@@ -1,5 +0,0 @@
1
- example_id | status | run_time |
2
- ------------------------------- | ------ | --------------- |
3
- ./spec/magento_spec.rb[1:1] | passed | 0.00057 seconds |
4
- ./spec/product_spec.rb[1:1:1:1] | passed | 0.00102 seconds |
5
- ./spec/product_spec.rb[1:1:2:1] | passed | 0.00111 seconds |