betsy 0.2.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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +15 -0
  5. data/CHANGELOG.md +9 -0
  6. data/CODE_OF_CONDUCT.md +84 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +237 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +79 -0
  11. data/Rakefile +12 -0
  12. data/app/controllers/betsy/response_listener_controller.rb +5 -0
  13. data/app/views/betsy/response_listener/etsy_response_listener.html.erb +1 -0
  14. data/betsy-0.1.0.gem +0 -0
  15. data/betsy.gemspec +44 -0
  16. data/bin/console +15 -0
  17. data/bin/setup +8 -0
  18. data/config/routes.rb +3 -0
  19. data/lib/betsy/engine.rb +11 -0
  20. data/lib/betsy/error.rb +10 -0
  21. data/lib/betsy/ledger_entry.rb +20 -0
  22. data/lib/betsy/model.rb +73 -0
  23. data/lib/betsy/other.rb +13 -0
  24. data/lib/betsy/payment.rb +44 -0
  25. data/lib/betsy/review.rb +22 -0
  26. data/lib/betsy/seller_taxonomy.rb +36 -0
  27. data/lib/betsy/shop.rb +69 -0
  28. data/lib/betsy/shop_listing.rb +124 -0
  29. data/lib/betsy/shop_listing_file.rb +32 -0
  30. data/lib/betsy/shop_listing_image.rb +42 -0
  31. data/lib/betsy/shop_listing_inventory.rb +21 -0
  32. data/lib/betsy/shop_listing_offering.rb +17 -0
  33. data/lib/betsy/shop_listing_product.rb +17 -0
  34. data/lib/betsy/shop_listing_translation.rb +25 -0
  35. data/lib/betsy/shop_listing_variation_image.rb +19 -0
  36. data/lib/betsy/shop_production_partner.rb +15 -0
  37. data/lib/betsy/shop_receipt.rb +54 -0
  38. data/lib/betsy/shop_receipt_transaction.rb +43 -0
  39. data/lib/betsy/shop_section.rb +25 -0
  40. data/lib/betsy/shop_shipping_profile.rb +105 -0
  41. data/lib/betsy/user.rb +27 -0
  42. data/lib/betsy/user_address.rb +27 -0
  43. data/lib/betsy/version.rb +5 -0
  44. data/lib/betsy.rb +121 -0
  45. data/lib/generators/betsy/install_generator.rb +35 -0
  46. data/lib/generators/betsy/templates/betsy.rb +9 -0
  47. data/lib/generators/betsy/templates/create_etsy_accounts.rb +14 -0
  48. data/lib/generators/betsy/templates/etsy_account.rb +2 -0
  49. metadata +206 -0
@@ -0,0 +1,73 @@
1
+ module Betsy
2
+ module Model
3
+ module ClassMethods
4
+ BASE_ETSY_API_URL = "https://openapi.etsy.com"
5
+
6
+ def attribute(name)
7
+ define_method name do
8
+ @result[name.to_s]
9
+ end
10
+ end
11
+
12
+ def make_request(request_type, endpoint, options = {})
13
+ check_token_expiration(options[:etsy_account]) if options[:etsy_account]
14
+ headers = access_credentials(options[:etsy_account])
15
+ options.delete(:etsy_account)
16
+ response = Faraday.method(request_type).call("#{BASE_ETSY_API_URL}#{endpoint}", options, headers)
17
+ handle_response(response)
18
+ end
19
+
20
+ def check_token_expiration(etsy_account)
21
+ if etsy_account.last_token_refresh + etsy_account.expires_in <= DateTime.now
22
+ options = {
23
+ grant_type: "refresh_token",
24
+ refresh_token: etsy_account.refresh_token,
25
+ client_id: Betsy.api_key
26
+ }
27
+ response = JSON.parse(Faraday.post("https://api.etsy.com/v3/public/oauth/token", options).body)
28
+ etsy_account.access_token = response["access_token"]
29
+ etsy_account.expires_in = response["expires_in"]
30
+ etsy_account.refresh_token = response["refresh_token"]
31
+ etsy_account.last_token_refresh = DateTime.now
32
+ etsy_account.save
33
+ end
34
+ end
35
+
36
+ def access_credentials(etsy_account)
37
+ header = {x_api_key: Betsy.api_key}
38
+ header[:Authorization] = "Bearer #{etsy_account.access_token}" if etsy_account.present?
39
+ header
40
+ end
41
+
42
+ def handle_response(response)
43
+ if response.status == 200
44
+ return nil if response.body.empty?
45
+ response = JSON.parse(response.body)
46
+ build_objects(response)
47
+ else
48
+ Betsy::Error.new(JSON.parse(response.body).merge!("status" => response.status))
49
+ end
50
+ end
51
+
52
+ def build_objects(response)
53
+ if response["count"].nil?
54
+ objects = new(response)
55
+ else
56
+ objects = []
57
+ response["results"].each do |data|
58
+ objects.append(new(data))
59
+ end
60
+ objects
61
+ end
62
+ end
63
+ end
64
+
65
+ def initialize(data = nil)
66
+ @result = data
67
+ end
68
+
69
+ def self.included(other)
70
+ other.extend(ClassMethods)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class Other
5
+ include Betsy::Model
6
+
7
+ attribute :application_id
8
+
9
+ def self.ping
10
+ make_request(:get, "/v3/application/openapi-ping")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class Payment
5
+ include Betsy::Model
6
+
7
+ attribute :payment_id
8
+ attribute :buyer_user_id
9
+ attribute :shop_id
10
+ attribute :receipt_id
11
+ attribute :amount_gross
12
+ attribute :amount_fees
13
+ attribute :amount_net
14
+ attribute :posted_gross
15
+ attribute :posted_fees
16
+ attribute :posted_net
17
+ attribute :adjusted_gross
18
+ attribute :adjusted_fees
19
+ attribute :adjusted_net
20
+ attribute :currency
21
+ attribute :shop_currency
22
+ attribute :buyer_currency
23
+ attribute :shipping_user_id
24
+ attribute :shipping_address_id
25
+ attribute :billing_address_id
26
+ attribute :status
27
+ attribute :shipped_timestamp
28
+ attribute :create_timestamp
29
+ attribute :update_timestamp
30
+ attribute :payment_adjustments
31
+
32
+ def self.get_payment_account_ledger_entry_payments(shop_id, options = {})
33
+ make_request(:get, "/v3/application/shops/#{shop_id}/payment-account/ledger-entries/payments", options)
34
+ end
35
+
36
+ def self.get_shop_payment_by_receipt_id(shop_id, receipt_id, options = {})
37
+ make_request(:get, "/v3/application/shops/#{shop_id}/receipts/#{receipt_id}/payments", options)
38
+ end
39
+
40
+ def self.get_payments(shop_id, options = {})
41
+ make_request(:get, "/v3/application/shops/#{shop_id}/payments", options)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class Review
5
+ include Betsy::Model
6
+
7
+ attribute :shop_id
8
+ attribute :listing_id
9
+ attribute :transaction_id
10
+ attribute :buyer_user_id
11
+ attribute :rating
12
+ attribute :review
13
+ attribute :language
14
+ attribute :image_url_fullxfull
15
+ attribute :create_timestamp
16
+ attribute :update_timestamp
17
+
18
+ def self.get_reviews_by_shop(shop_id, options = {})
19
+ make_request(:get, "/v3/application/shops/#{shop_id}/reviews", options)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class SellerTaxonomy
5
+ include Betsy::Model
6
+
7
+ # taxonomy nodes
8
+ attribute :id
9
+ attribute :level
10
+ attribute :parent_id
11
+ attribute :children
12
+ attribute :full_path_taxonomy_ids
13
+
14
+ # taxonomy nodes properties
15
+ attribute :property_id
16
+ attribute :display_name
17
+ attribute :scales
18
+ attribute :is_required
19
+ attribute :supports_attributes
20
+ attribute :supports_variations
21
+ attribute :is_multivalued
22
+ attribute :possible_values
23
+ attribute :selected_values
24
+
25
+ # both nodes and node properties
26
+ attribute :name
27
+
28
+ def self.get_seller_taxonomy_nodes
29
+ make_request(:get, "/v3/application/seller-taxonomy/nodes")
30
+ end
31
+
32
+ def self.get_properties_by_taxonomy_id(taxonomy_id)
33
+ make_request(:get, "/v3/application/seller-taxonomy/nodes/#{taxonomy_id}/properties")
34
+ end
35
+ end
36
+ end
data/lib/betsy/shop.rb ADDED
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class Shop
5
+ include Betsy::Model
6
+
7
+ attribute :shop_id
8
+ attribute :user_id
9
+ attribute :shop_name
10
+ attribute :create_date
11
+ attribute :title
12
+ attribute :announcement
13
+ attribute :currency_code
14
+ attribute :is_vacation
15
+ attribute :vacation_message
16
+ attribute :sale_message
17
+ attribute :digital_sale_message
18
+ attribute :update_date
19
+ attribute :listing_active_count
20
+ attribute :digital_listing_count
21
+ attribute :login_name
22
+ attribute :accepts_custom_requests
23
+ attribute :policy_welcome
24
+ attribute :policy_payment
25
+ attribute :policy_shipping
26
+ attribute :policy_refunds
27
+ attribute :policy_additional
28
+ attribute :policy_seller_info
29
+ attribute :policy_update_date
30
+ attribute :policy_has_private_receipt_info
31
+ attribute :has_unstructured_policies
32
+ attribute :policy_privacy
33
+ attribute :vacation_autoreply
34
+ attribute :url
35
+ attribute :image_url_760x100
36
+ attribute :num_favorers
37
+ attribute :languages
38
+ attribute :icon_url_fullxfull
39
+ attribute :is_using_structured_policies
40
+ attribute :has_onboarded_structured_policies
41
+ attribute :include_dispute_form_link
42
+ attribute :is_direct_checkout_onboarded
43
+ attribute :is_calculated_eligible
44
+ attribute :is_opted_in_to_buyer_promise
45
+ attribute :is_shop_us_based
46
+ attribute :transaction_sold_count
47
+ attribute :shipping_from_country_iso
48
+ attribute :shop_location_country_iso
49
+ attribute :review_count
50
+ attribute :review_average
51
+
52
+ def self.get_shop(shop_id)
53
+ make_request(:get, "/v3/application/shops/#{shop_id}")
54
+ end
55
+
56
+ def self.update_shop(shop_id, options = {})
57
+ make_request(:put, "/v3/application/shops/#{shop_id}", options)
58
+ end
59
+
60
+ def self.get_shop_by_owner_user_id(user_id)
61
+ make_request(:get, "/v3/application/users/#{user_id}/shops")
62
+ end
63
+
64
+ def self.find_shops(shop_name, options = {})
65
+ options[:shop_name] = shop_name
66
+ make_request(:get, "/v3/application/shops", options)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListing
5
+ include Betsy::Model
6
+
7
+ # listing
8
+ attribute :listing_id
9
+ attribute :user_id
10
+ attribute :shop_id
11
+ attribute :title
12
+ attribute :description
13
+ attribute :state
14
+ attribute :creation_timestamp
15
+ attribute :ending_timestamp
16
+ attribute :original_creation_timestamp
17
+ attribute :last_modified_timestamp
18
+ attribute :state_timestamp
19
+ attribute :quantity
20
+ attribute :shop_section_id
21
+ attribute :featured_rank
22
+ attribute :url
23
+ attribute :num_favorers
24
+ attribute :non_taxable
25
+ attribute :is_customizable
26
+ attribute :is_personalizable
27
+ attribute :personalization_is_required
28
+ attribute :personalization_char_count_max
29
+ attribute :personalization_instructions
30
+ attribute :listing_type
31
+ attribute :tags
32
+ attribute :materials
33
+ attribute :shipping_profile_id
34
+ attribute :processing_min
35
+ attribute :processing_max
36
+ attribute :who_made
37
+ attribute :when_made
38
+ attribute :is_supply
39
+ attribute :item_weight
40
+ attribute :item_weight_unit
41
+ attribute :item_length
42
+ attribute :item_width
43
+ attribute :item_height
44
+ attribute :item_dimensions_unit
45
+ attribute :is_private
46
+ attribute :recipient
47
+ attribute :occasion
48
+ attribute :style
49
+ attribute :file_data
50
+ attribute :has_variations
51
+ attribute :should_auto_renew
52
+ attribute :language
53
+ attribute :price
54
+ attribute :taxonomy_id
55
+
56
+ # listing properties
57
+ attribute :property_id
58
+ attribute :property_name
59
+ attribute :scale_id
60
+ attribute :scale_name
61
+ attribute :value_ids
62
+ attribute :values
63
+
64
+ def self.create_draft_listing(shop_id, options = {})
65
+ make_request(:post, "/v3/application/shops/#{shop_id}/listings", options)
66
+ end
67
+
68
+ def self.get_listings_by_shop(shop_id, options = {})
69
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings", options)
70
+ end
71
+
72
+ def self.delete_listing(listing_id, options = {})
73
+ make_request(:delete, "/v3/application/listings/#{listing_id}", options)
74
+ end
75
+
76
+ def self.get_listing(listing_id, options = {})
77
+ make_request(:get, "/v3/application/listings/#{listing_id}", options)
78
+ end
79
+
80
+ def self.find_all_listings_active(options = {})
81
+ make_request(:get, "/v3/application/listings/active", options)
82
+ end
83
+
84
+ def self.find_all_active_listings_by_shop(shop_id, options = {})
85
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/active", options)
86
+ end
87
+
88
+ def self.get_listings_by_listing_ids(options = {})
89
+ make_request(:get, "/v3/application/listings/batch", options)
90
+ end
91
+
92
+ def self.get_featured_listings_by_shop(shop_id, options = {})
93
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/featured", options)
94
+ end
95
+
96
+ def self.delete_listing_property(shop_id, listing_id, property_id, options = {})
97
+ make_request(:delete, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/properties/#{property_id}", options)
98
+ end
99
+
100
+ def self.update_listing_property(shop_id, listing_id, property_id, options = {})
101
+ make_request(:put, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/properties/#{property_id}", options)
102
+ end
103
+
104
+ # STILL IN DEVELOPMENT AS OF 8/28/2021
105
+ def self.get_listing_property
106
+ end
107
+
108
+ def self.get_listing_properties(shop_id, listing_id)
109
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/properties")
110
+ end
111
+
112
+ def self.update_listing(shop_id, listing_id, options = {})
113
+ make_request(:put, "/v3/application/shops/#{shop_id}/listings/#{listing_id}", options)
114
+ end
115
+
116
+ def self.get_listings_by_shop_receipt(shop_id, receipt_id, options = {})
117
+ make_request(:get, "/v3/application/shops/#{shop_id}/receipts/#{receipt_id}/listings", options)
118
+ end
119
+
120
+ def self.get_listings_by_shop_section_id(shop_id, options = {})
121
+ make_request(:get, "/v3/application/shops/#{shop_id}/shop-sections/listings", options)
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListingFile
5
+ include Betsy::Model
6
+
7
+ attribute :listing_file_id
8
+ attribute :listing_id
9
+ attribute :rank
10
+ attribute :filename
11
+ attribute :filesize
12
+ attribute :size_bytes
13
+ attribute :filetype
14
+ attribute :create_timestamp
15
+
16
+ def self.delete_listing_file(shop_id, listing_id, listing_file_id, options = {})
17
+ make_request(:delete, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/files/#{listing_file_id}", options)
18
+ end
19
+
20
+ def self.get_listing_file(shop_id, listing_id, listing_file_id, options = {})
21
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/files/#{listing_file_id}", options)
22
+ end
23
+
24
+ def self.get_all_listing_files(shop_id, listing_id, options = {})
25
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/files", options)
26
+ end
27
+
28
+ def self.upload_listing_file(shop_id, listing_id, options = {})
29
+ make_request(:post, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/files", options)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListingImage
5
+ include Betsy::Model
6
+
7
+ attribute :listing_id
8
+ attribute :listing_image_id
9
+ attribute :hex_code
10
+ attribute :red
11
+ attribute :green
12
+ attribute :blue
13
+ attribute :hue
14
+ attribute :saturation
15
+ attribute :brightness
16
+ attribute :is_black_and_white
17
+ attribute :creation_tsz
18
+ attribute :rank
19
+ attribute :url_75x75
20
+ attribute :url_170x135
21
+ attribute :url_570xN
22
+ attribute :url_fullxfull
23
+ attribute :full_height
24
+ attribute :full_width
25
+
26
+ def self.delete_listing_image(shop_id, listing_id, listing_image_id, options = {})
27
+ make_request(:delete, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/images/#{listing_image_id}", options)
28
+ end
29
+
30
+ def self.get_listing_image(shop_id, listing_id, listing_image_id)
31
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/images/#{listing_image_id}")
32
+ end
33
+
34
+ def self.get_listing_images(shop_id, listing_id)
35
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/images")
36
+ end
37
+
38
+ def self.upload_listing_image(shop_id, listing_id, options = {})
39
+ make_request(:post, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/images", options)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListingInventory
5
+ include Betsy::Model
6
+
7
+ attribute :products
8
+ attribute :price_on_property
9
+ attribute :quantity_on_property
10
+ attribute :sku_on_property
11
+ attribute :listing
12
+
13
+ def self.get_listing_inventory(listing_id, options = {})
14
+ make_request(:get, "/v3/application/listings/#{listing_id}/inventory", options)
15
+ end
16
+
17
+ def self.update_listing_inventory(listing_id, options = {})
18
+ make_request(:put, "/v3/application/listings/#{listing_id}/inventory", options)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListingOffering
5
+ include Betsy::Model
6
+
7
+ attribute :offering_id
8
+ attribute :quantity
9
+ attribute :is_enabled
10
+ attribute :is_deleted
11
+ attribute :price
12
+
13
+ def self.get_listing_offering(listing_id, product_id, product_offering_id)
14
+ make_request(:get, "/v3/application/listings/#{listing_id}/products/#{product_id}/offerings/#{product_offering_id}")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListingProduct
5
+ include Betsy::Model
6
+
7
+ attribute :product_id
8
+ attribute :sku
9
+ attribute :is_deleted
10
+ attribute :offerings
11
+ attribute :property_values
12
+
13
+ def self.get_listing_product(listing_id, product_id, options = {})
14
+ make_request(:get, "/v3/application/listings/#{listing_id}/inventory/products/#{product_id}", options)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListingTranslation
5
+ include Betsy::Model
6
+
7
+ attribute :listing_id
8
+ attribute :language
9
+ attribute :title
10
+ attribute :description
11
+ attribute :tags
12
+
13
+ def self.create_listing_translation(shop_id, listing_id, language, options = {})
14
+ make_request(:post, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/translations/#{language}", options)
15
+ end
16
+
17
+ def self.get_listing_translation(shop_id, listing_id, language)
18
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/translations/#{language}")
19
+ end
20
+
21
+ def self.update_listing_translation(shop_id, listing_id, language, options = {})
22
+ make_request(:put, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/translations/#{language}", options)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopListingVariationImage
5
+ include Betsy::Model
6
+
7
+ attribute :property_id
8
+ attribute :value_id
9
+ attribute :image_id
10
+
11
+ def self.get_listing_variation_images(shop_id, listing_id)
12
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/variation-images")
13
+ end
14
+
15
+ def self.update_variation_images(shop_id, listing_id, options = {})
16
+ make_request(:post, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/variation-images", options)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopProductionPartner
5
+ include Betsy::Model
6
+
7
+ attribute :production_partner_id
8
+ attribute :partner_name
9
+ attribute :location
10
+
11
+ def self.get_shop_production_partners(shop_id, options = {})
12
+ make_request(:get, "/v3/application/shops/#{shop_id}/production-partners", options)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopReceipt
5
+ include Betsy::Model
6
+
7
+ attribute :receipt_id
8
+ attribute :receipt_type
9
+ attribute :seller_user_id
10
+ attribute :seller_email
11
+ attribute :buyer_user_id
12
+ attribute :buyer_email
13
+ attribute :name
14
+ attribute :first_line
15
+ attribute :second_line
16
+ attribute :city
17
+ attribute :state
18
+ attribute :zip
19
+ attribute :formatted_address
20
+ attribute :country_iso
21
+ attribute :payment_method
22
+ attribute :payment_email
23
+ attribute :message_from_seller
24
+ attribute :message_from_buyer
25
+ attribute :message_from_payment
26
+ attribute :is_paid
27
+ attribute :is_shipped
28
+ attribute :create_timestamp
29
+ attribute :update_timestamp
30
+ attribute :gift_message
31
+ attribute :grandtotal
32
+ attribute :subtotal
33
+ attribute :total_price
34
+ attribute :total_shipping_cost
35
+ attribute :total_tax_cost
36
+ attribute :total_vat_cost
37
+ attribute :discount_amt
38
+ attribute :gift_wrap_price
39
+ attribute :shipments
40
+ attribute :transactions
41
+
42
+ def self.get_shop_receipt(shop_id, receipt_id, options = {})
43
+ make_request(:get, "/v3/application/shops/#{shop_id}/receipts/#{receipt_id}", options)
44
+ end
45
+
46
+ def self.get_shop_receipts(shop_id, options = {})
47
+ make_request(:get, "/v3/application/shops/#{shop_id}/receipts", options)
48
+ end
49
+
50
+ def self.create_receipt_shipment(shop_id, receipt_id, options = {})
51
+ make_request(:post, "/v3/application/shops/#{shop_id}/receipts/#{receipt_id}/tracking", options)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Betsy
4
+ class ShopReceiptTransaction
5
+ include Betsy::Model
6
+
7
+ attribute :transaction_id
8
+ attribute :title
9
+ attribute :description
10
+ attribute :seller_user_id
11
+ attribute :buyer_user_id
12
+ attribute :create_timestamp
13
+ attribute :paid_timestamp
14
+ attribute :shipped_timestamp
15
+ attribute :quantity
16
+ attribute :listing_image_id
17
+ attribute :receipt_id
18
+ attribute :is_digital
19
+ attribute :file_data
20
+ attribute :listing_id
21
+ attribute :transaction_type
22
+ attribute :product_id
23
+ attribute :price
24
+ attribute :shipping_cost
25
+ attribute :variations
26
+
27
+ def self.get_shop_receipt_transactions_by_listing(shop_id, listing_id, options = {})
28
+ make_request(:get, "/v3/application/shops/#{shop_id}/listings/#{listing_id}/transactions", options)
29
+ end
30
+
31
+ def self.get_shop_receipt_transactions_by_receipt(shop_id, receipt_id, options = {})
32
+ make_request(:get, "/v3/application/shops/#{shop_id}/receipts/#{receipt_id}/transactions", options)
33
+ end
34
+
35
+ def self.get_shop_receipt_transaction(shop_id, transaction_id, options = {})
36
+ make_request(:get, "/v3/application/shops/#{shop_id}/transactions/#{transaction_id}", options)
37
+ end
38
+
39
+ def self.get_shop_receipt_transactions_by_shop(shop_id, options = {})
40
+ make_request(:get, "/v3/application/shops/#{shop_id}/transactions", options)
41
+ end
42
+ end
43
+ end