amazon_bundler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/amazon_bundler.rb +23 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1519dcc8d71e9b513eeb886300b03f41b92c0d8d359daa5d78c6665ab489aeae
|
4
|
+
data.tar.gz: ca62a1f7f261d64ec735c54edaea4dc0c3987e29d2be3ed3a9b71b7aced11ee8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10657336353400e1f4bdcee55c773c14cdceb3c1fe0f31075f17647fbd31e440ad511c306faf60574f5d3bb57c84c1ec4331decced0579543b1a37452be1197d
|
7
|
+
data.tar.gz: 3cff512eae8504684d5e7540a121c7953421631aeed35e4f955c49357f70da09ea34e872e59982d24574eef24955c58b21928eab04be262dc5a9891f6d902ddc
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Creates a one-click url to add a bundle of Amazon products to cart
|
4
|
+
module AmazonBundler
|
5
|
+
def self.convert_products_to_url(product_hash)
|
6
|
+
product_hash.each_with_index.map { |product, index| convert_product_to_url(product, index) }.join('&')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.convert_product_to_url(product, index)
|
10
|
+
asin = "ASIN.#{index + 1}=#{product[:asin]}"
|
11
|
+
quantity = "Quantity.#{index + 1}=#{product[:quantity]}"
|
12
|
+
offer = product[:offer_id].nil? ? '' : "OfferListingId.#{index + 1}=#{product[:offer_id]}"
|
13
|
+
[asin, quantity, offer].join('&')
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create_bundle_link(product_hash: {}, affiliate_id: nil)
|
17
|
+
base_url = 'https://www.amazon.com/gp/aws/cart/add.html?'
|
18
|
+
affiliate_info = affiliate_id ? "AssociateTag=#{affiliate_id}&" : ''
|
19
|
+
products = convert_products_to_url(product_hash)
|
20
|
+
"#{base_url}#{affiliate_info}#{products}"
|
21
|
+
end
|
22
|
+
'https://www.amazon.com/gp/aws/cart/add.html?AssociateTag=your_tag&tag=your_tagQ&ASIN.1=B012NH05UW&Quantity.1=1&ASIN.2=B012M8LXQW&Quantity.2=1'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amazon_bundler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bobby Meyer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-05-02 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Formats lists of ASINs for creating single click bundles of Amazon products
|
14
|
+
email: bobby@bobbymeyer.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/amazon_bundler.rb
|
20
|
+
homepage: https://rubygems.org/gems/amazon_bundler
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.7.0
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.3.7
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Bundle Amazon products and add to cart with one-click
|
43
|
+
test_files: []
|