solidus_tiny 1.2.0 → 2.1.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: d1b3c9f3b5c8c5b02751c0add8312a5ab8f680fae4d66d90f31e2170d6e6c3bc
4
- data.tar.gz: 3776c86a2865a04f79a38e0e2794af9af81dd0f957b43d7e0af9a80b941b15ff
3
+ metadata.gz: 90a782a62f3f9e3dd20d682c3560fc02e14c070b2e03cde8bfdcc13385511412
4
+ data.tar.gz: 4b4a0f7ac5658e3e6eb390dd423a2f0944ff130a5efbe8db154407d417fe9ce6
5
5
  SHA512:
6
- metadata.gz: 6ad9cca4e3235e38b80912b7b01f297063a1b22ce669f21915db56812e15629171160755e25c579a6110f218cfe72e02f9a61183713ac189f8b2a246fd4c47cb
7
- data.tar.gz: 9c65758d8f7991bcb5408b9a9f25752b59ff4b20fb4dd25d3f6e3d9c320fb56feec7b9e63d6957e2fd10eac4fdb16011d6ff74435d9dc2f5deac75fd6344cdfe
6
+ metadata.gz: c4f9a7f571f1c8e2ebc0be5fbf0c50965cd2c1bfd885ea72247f6c88c59ed427fd13c2734c5aaee2a1cd6017e5eb9a084fc5b50b5870de0136254d1b37b555f0
7
+ data.tar.gz: 3c30abecb9e749fbf5c8136add16eb6a47a4c99c349fe162cf31a5c655cc691f265b9dbf7a800693b833bad26d8c97a9a95f526dfedd2ea0489c896a15e4a115
@@ -43,7 +43,7 @@ module Spree
43
43
  end
44
44
 
45
45
  def update
46
- @tiny_account.sellers.find_by(seller_params[:default_seller]).update(default: true)
46
+ @tiny_account.sellers.find_by(id: seller_params[:default_seller_id]).update(default: true)
47
47
  @tiny_account.update account_params
48
48
  redirect_to edit_admin_solidus_tiny_account_path(@tiny_account.id)
49
49
  end
@@ -59,6 +59,16 @@ module Spree
59
59
  redirect_to admin_solidus_tiny_accounts_path
60
60
  end
61
61
 
62
+ def authorize
63
+ tiny_account = ::SolidusTiny::Account.first
64
+ code = params[:code]
65
+ unless tiny_account.authorize(code: code)
66
+ tiny_account.errors.add(:base, "Erro ao autorizar aplicativo 🦆")
67
+ flash[:error] = tiny_account.errors.full_messages.join("\n")
68
+ end
69
+ redirect_to edit_admin_solidus_tiny_account_path(tiny_account.id)
70
+ end
71
+
62
72
  private
63
73
 
64
74
  def set_account
@@ -67,14 +77,14 @@ module Spree
67
77
 
68
78
  def account_params
69
79
  params.require(:account).permit(
70
- :api_key, :operation_id, :stock_location,
80
+ :api_key, :operation_id, :stock_location, :client_id, :client_secret, :redirect_url, :state,
71
81
  payment_methods_attributes: [:id, :spree_payment_method_id, :alias],
72
- shipping_methods_attributes: [:id, :spree_shipping_method_id, :company, :name, :service]
82
+ shipping_methods_attributes: [:id, :spree_shipping_method_id, :id_transportador, :id_forma_envio, :id_forma_frete]
73
83
  )
74
84
  end
75
85
 
76
86
  def seller_params
77
- params.require(:account).permit(default_seller: [:id])
87
+ params.require(:account).permit(:default_seller_id)
78
88
  end
79
89
  end
80
90
  end
@@ -4,5 +4,19 @@ module SolidusTiny
4
4
  has_many :shipping_methods, dependent: :destroy
5
5
  has_many :sellers, dependent: :destroy
6
6
  accepts_nested_attributes_for :payment_methods, :shipping_methods, :sellers
7
+
8
+ def authorize(code:)
9
+ client = ::SolidusTiny::TinyClient.for_account(self)
10
+ client.authorize(code: code, redirect_url: redirect_url)
11
+ update(
12
+ refresh_token: client.get_refresh_token,
13
+ access_token: client.access_token,
14
+ token_expires_in: client.token_expires_at
15
+ )
16
+ end
17
+
18
+ def authorization_url
19
+ "https://accounts.tiny.com.br/realms/tiny/protocol/openid-connect/auth?client_id=#{client_id}&redirect_uri=#{redirect_url}&response_type=code&state=#{state}"
20
+ end
7
21
  end
8
22
  end
@@ -1,77 +1,75 @@
1
1
  module SolidusTiny
2
2
  class Order
3
- def initialize spree_order, account=SolidusTiny::Account.first
3
+
4
+ attr_reader :order
5
+ def initialize spree_order
4
6
  @order = spree_order
5
- @account = account
6
7
  end
7
8
 
8
9
  def send
9
- tiny_event = SolidusTiny::Event.new(internal_id: @order.id)
10
- begin
11
- TinyErpApi.configure { |config| config.access_token = @account.api_key }
12
- tiny_shipping_method = transportador
13
- order_body = {
14
- data_pedido: @order.completed_at.strftime("%d/%m/%Y"),
15
- transportador: tiny_shipping_method.company,
16
- forma_pagamento: forma_pagamento,
17
- valor_frete: @order.shipment_total,
18
- valor_desconto: @order.adjustment_total.abs,
19
- numero_pedido: @order.number,
20
- observacoes: "Número do pedido loja: #{@order.number}",
21
- parcelas: parcelas,
22
- observacoes_internas: observacoes_internas,
23
- forma_envio: tiny_shipping_method.name,
24
- forma_frete: tiny_shipping_method.service,
25
- cliente: customer,
26
- itens: products,
27
- id_vendedor: seller_external_id,
28
- deposito: @account.stock_location,
29
- id_natureza_operacao: @account.operation_id
30
- }
31
- tiny_event.body = order_body
32
-
33
- tiny_order = TinyErpApi::Order.new(**order_body).create
34
-
35
- if tiny_order
36
- @order.update(tiny_order_id: tiny_order.id)
37
- tiny_event.status = "success"
38
- tiny_event.message = "Pedido enviado"
39
- end
40
- rescue => e
41
- tiny_event.status = "error"
42
- tiny_event.message = e.to_json
43
- ensure
44
- tiny_event.save!
45
- end
10
+ @account = SolidusTiny::Account.first
11
+ @client = SolidusTiny::TinyClient.for_account(@account)
12
+
13
+ contato = upsert_contact
14
+ itens = build_tiny_items
15
+ id_vendedor = seller_external_id
16
+ endereco_entrega = build_tiny_address
17
+ transportador = build_tiny_shipment
18
+ parcelas = build_tiny_installments
19
+
20
+ order_response = @client.create_order(
21
+ data: @order.completed_at.strftime("%Y-%m-%d"),
22
+ id_contato: contato.id,
23
+ itens: itens,
24
+ valor_desconto: @order.adjustment_total.abs,
25
+ valor_frete: @order.shipment_total.to_f,
26
+ id_natureza_operacao: @account.operation_id,
27
+ id_vendedor: id_vendedor,
28
+ endereco_entrega: endereco_entrega,
29
+ numero_pedido_ecommerce: @order.number,
30
+ transportador: transportador,
31
+ id_deposito: @account.stock_location,
32
+ parcelas: parcelas,
33
+ observacoes: build_observacoes,
34
+ observacoes_internas: observacoes_internas
35
+ )
36
+ @order.update(tiny_order_id: order_response.id)
37
+ @client.add_order_tags(order_response.id, SolidusTiny.config.order_tags) if SolidusTiny.configuration.order_tags.any?
46
38
  end
47
39
 
48
- def customer
49
- ship_address = @order.ship_address
50
- {
51
- nome: ship_address.name,
52
- tipo_pessoa: @order.tax_id.length > 14 ? "J" : "F",
53
- cpf_cnpj: @order.tax_id,
54
- endereco: ship_address.address1,
55
- numero: ship_address.number,
56
- complemento: ship_address.address2,
57
- bairro: ship_address.district,
58
- cep: ship_address.zipcode,
59
- cidade: ship_address.city,
60
- uf: ship_address.state.abbr,
61
- fone: ship_address.phone,
62
- email: @order.email
63
- }
40
+ def upsert_contact
41
+ search_contato = @client.find_contact_by_document(@order.tax_id).itens
42
+ contact_id = if search_contato.any?
43
+ @client.update_contact(
44
+ id: search_contato[0].id,
45
+ nome: @order.ship_address.name,
46
+ tipo_pessoa: @order.tax_id.length > 14 ? "J" : "F",
47
+ cpf_cnpj: @order.tax_id,
48
+ **build_customer_infos
49
+ )
50
+ search_contato[0].id
51
+ else
52
+ response = @client.create_contact(
53
+ nome: @order.ship_address.name,
54
+ tipo_pessoa: @order.tax_id.length > 14 ? "J" : "F",
55
+ cpf_cnpj: @order.tax_id,
56
+ **build_customer_infos
57
+ )
58
+ response.id
59
+ end
60
+ @client.get_contact(contact_id)
64
61
  end
65
62
 
66
- def products
63
+ def build_tiny_items
67
64
  @order.line_items.map do |item|
68
- {
69
- item: {
70
- codigo: item.sku,
71
- quantidade: item.quantity,
72
- valor_unitario: item.price
73
- }
74
- }
65
+ api_product = @client.get_product_by_sku(item.sku).itens
66
+ raise "Produto com SKU #{item.sku} não encontrado no Tiny" if api_product.blank?
67
+ TinyErpApi::Item.new(
68
+ id_produto: api_product[0].id,
69
+ tipo: "P",
70
+ quantidade: item.quantity,
71
+ valor_unitario: item.price
72
+ )
75
73
  end
76
74
  end
77
75
 
@@ -79,26 +77,48 @@ module SolidusTiny
79
77
  @order.solidus_tiny_seller_id ? @account.sellers.find(@order.solidus_tiny_seller_id).external_id : SolidusTiny::Seller.default.external_id
80
78
  end
81
79
 
82
- def transportador
83
- @account.shipping_methods.find_by(spree_shipping_method_id: @order.shipments.last.shipping_method.id)
80
+ def build_tiny_address
81
+ ship_address = @order.ship_address
82
+ TinyErpApi::Address.new(
83
+ endereco: ship_address.address1,
84
+ endereco_numero: ship_address.number,
85
+ complemento: ship_address.address2,
86
+ bairro: ship_address.district,
87
+ municipio: ship_address.city,
88
+ cep: ship_address.zipcode,
89
+ uf: ship_address.state.abbr,
90
+ fone: ship_address.phone,
91
+ nome_destinatario: ship_address.name,
92
+ cpf_cnpj: @order.tax_id,
93
+ tipo_pessoa: @order.tax_id.length > 14 ? "J" : "F"
94
+ )
95
+ end
96
+
97
+ def build_tiny_shipment
98
+ selected_shipping_method = @account
99
+ .shipping_methods
100
+ .find_by(spree_shipping_method_id: @order.shipments.last.shipping_method.id)
101
+ TinyErpApi::Shipment.new(
102
+ id_transportador: selected_shipping_method.id_transportador,
103
+ id_forma_envio: selected_shipping_method.id_forma_envio,
104
+ id_forma_frete: selected_shipping_method.id_forma_frete
105
+ )
84
106
  end
85
107
 
86
- def forma_pagamento
108
+ def id_forma_recebimento
87
109
  spree_payment = @order.payments.valid.last
88
- payment_method = @account.payment_methods.find_by(spree_payment_method_id: spree_payment.payment_method_id).alias
110
+ @account.payment_methods.find_by(spree_payment_method_id: spree_payment.payment_method_id).alias
89
111
  end
90
112
 
91
- def parcelas
113
+ def build_tiny_installments
92
114
  parcelas = @order.payments.last.source.try(:installments) || 1
93
115
  valor_parcela = @order.total.to_f / parcelas
94
116
  1.upto(parcelas).map do |parcela|
95
- {
96
- parcela: {
97
- data: (@order.completed_at + parcela.months).strftime("%d/%m/%Y"),
98
- valor: valor_parcela,
99
- forma_pagamento: forma_pagamento
100
- }
101
- }
117
+ TinyErpApi::Installment.new(
118
+ data: (@order.completed_at + parcela.months).strftime("%Y-%m-%d"),
119
+ valor: valor_parcela,
120
+ id_forma_recebimento: id_forma_recebimento
121
+ )
102
122
  end
103
123
  end
104
124
 
@@ -125,5 +145,25 @@ module SolidusTiny
125
145
  "Link para o pedido: #{@order.store.url}/pedidos/#{@order.number}"
126
146
  end
127
147
 
148
+ def build_customer_infos
149
+ ship_address = @order.ship_address
150
+ {
151
+ email: @order.email,
152
+ celular: ship_address.phone,
153
+ endereco: ship_address.address1,
154
+ endereco_numero: ship_address.number,
155
+ endereco_complemento: ship_address.address2,
156
+ endereco_bairro: ship_address.district,
157
+ endereco_cep: ship_address.zipcode,
158
+ endereco_municipio: ship_address.city,
159
+ endereco_uf: ship_address.state.abbr,
160
+ endereco_pais: "Brasil",
161
+ }
162
+ end
163
+
164
+ # Sobreescreva esse método para customizar as observações internas do pedido no Tiny
165
+ def build_observacoes
166
+ "Pedido realizado no e-commerce #{build_order_url}"
167
+ end
128
168
  end
129
169
  end
@@ -8,19 +8,24 @@ module SolidusTiny
8
8
  after_save :falsify_all_others
9
9
 
10
10
  def self.upsert_sellers account
11
- TinyErpApi.configure { |config| config.access_token = account.api_key }
12
- sellers = TinyErpApi::Seller.get_all
13
- upsert_sellers = sellers.map do |seller|
14
- situacao = seller[:situacao] == "Ativo" ? true : false
15
- {
16
- name: seller[:nome],
17
- external_id: seller[:id],
18
- account_id: account.id,
19
- active: situacao
20
- }
11
+ client = SolidusTiny::TinyClient.for_account(account)
12
+ response = client.get_sellers(1)
13
+ total_pages = (response.paginacao.total / 100.0).ceil
14
+
15
+ upsert_sellers = []
16
+ 0.upto(total_pages - 1) do |page|
17
+ response = client.get_sellers(100, (page * 100))
18
+ response.itens.map do |seller|
19
+ upsert_sellers << {
20
+ name: seller.contato.nome,
21
+ external_id: seller.id,
22
+ account_id: account.id,
23
+ active: seller.situacao == "A" ? true : false
24
+ }
25
+ end
26
+ SolidusTiny::Seller.upsert_all(upsert_sellers, unique_by: :external_id)
27
+ inactivate_sellers(response.itens)
21
28
  end
22
- SolidusTiny::Seller.upsert_all(upsert_sellers, unique_by: :external_id)
23
- inactivate_sellers(sellers)
24
29
  end
25
30
 
26
31
  def self.default
@@ -1,8 +1,8 @@
1
1
  module SolidusTiny
2
2
  class ShippingMethod < ApplicationRecord
3
- validates :service, presence: true
4
- validates :name, presence: true
5
- validates :company, presence: true
3
+ validates :id_transportador, presence: true
4
+ validates :id_forma_envio, presence: true
5
+ validates :id_forma_frete, presence: true
6
6
 
7
7
  belongs_to :account
8
8
  belongs_to :spree_shipping_method, class_name: "Spree::ShippingMethod"
@@ -0,0 +1,34 @@
1
+ module SolidusTiny
2
+ class TinyClient < ::TinyErpApi::Client
3
+ def self.for_account(account)
4
+ self.new(account)
5
+ end
6
+
7
+ attr_accessor :account
8
+ def initialize(account)
9
+ @account = account
10
+ super(
11
+ client_id: account.client_id,
12
+ client_secret: account.client_secret,
13
+ refresh: account.refresh_token,
14
+ access_token: account.access_token,
15
+ token_expires_at: account.token_expires_in
16
+ )
17
+ end
18
+
19
+ def refresh_token
20
+ super
21
+ sync_account_tokens
22
+ end
23
+
24
+ private
25
+
26
+ def sync_account_tokens
27
+ account.update!(
28
+ access_token: access_token,
29
+ refresh_token: get_refresh_token,
30
+ token_expires_in: token_expires_at
31
+ )
32
+ end
33
+ end
34
+ end
@@ -3,29 +3,59 @@
3
3
  <legend>
4
4
  Dados da Conta
5
5
  </legend>
6
- <div class="row">
7
- <div class="col-12">
8
- <%= form.field_container :api_key do %>
9
- <%= form.label :api_key, "API Key", class: 'required' %>
10
- <%= form.text_field :api_key, required: true, class: 'fullwidth' %>
11
- <%= form.error_message_on :api_key %>
12
- <% end %>
13
- </div>
14
- <div class="col-md-6 col-12">
15
- <%= form.field_container :stock_location do %>
16
- <%= form.label :stock_location, "Depósito", class: 'required' %>
17
- <%= form.text_field :stock_location, required: true, class: 'fullwidth' %>
18
- <%= form.error_message_on :stock_location %>
19
- <% end %>
20
- </div>
21
- <div class="col-md-6 col-12">
22
- <%= form.field_container :operation_id do %>
23
- <%= form.label :operation_id, "ID Natureza de Operação", class: 'required' %>
24
- <%= form.text_field :operation_id, required: true, class: 'fullwidth' %>
25
- <%= form.error_message_on :operation_id %>
26
- <% end %>
6
+ <div class="row">
7
+ <div class="col-12 col-md-6">
8
+
9
+ <%= form.field_container :client_id do %>
10
+ <%= form.label :client_id, "Client ID", class: 'required' %>
11
+ <%= form.text_field :client_id, required: true, class: 'fullwidth' %>
12
+ <%= form.error_message_on :client_id %>
13
+ <% end %>
14
+
15
+ <% if !tiny_account.id %>
16
+ <%= form.field_container :client_secret do %>
17
+ <%= form.label :client_secret, "Client Secret", class: 'required' %>
18
+ <%= form.text_field :client_secret, required: true, class: 'fullwidth' %>
19
+ <%= form.error_message_on :client_secret %>
20
+ <% end %>
21
+ <% end %>
22
+
23
+ <%= form.field_container :stock_location do %>
24
+ <%= form.label :stock_location, "Depósito", class: 'required' %>
25
+ <%= form.text_field :stock_location, required: true, class: 'fullwidth' %>
26
+ <%= form.error_message_on :stock_location %>
27
+ <% end %>
28
+
29
+ <%= form.field_container :operation_id do %>
30
+ <%= form.label :operation_id, "ID Natureza de Operação", class: 'required' %>
31
+ <%= form.text_field :operation_id, required: true, class: 'fullwidth' %>
32
+ <%= form.error_message_on :operation_id %>
33
+ <% end %>
34
+
35
+ </div>
36
+
37
+ <div class="col-12 col-md-6">
38
+
39
+ <%= form.field_container :redirect_url do %>
40
+ <%= form.label :redirect_url, "Redirect URL", class: 'required' %>
41
+ <%= form.text_field :redirect_url, required: true, class: 'fullwidth' %>
42
+ <%= form.error_message_on :redirect_url %>
43
+ <% end %>
44
+
45
+ <%= form.field_container :state do %>
46
+ <%= form.label :state, "State", class: 'required' %>
47
+ <%= form.text_field :state, required: true, class: 'fullwidth' %>
48
+ <%= form.error_message_on :state %>
49
+ <% end %>
50
+
51
+ <div class="field">
52
+ <%= label_tag :token_expires_in, "Token Expiration" %>
53
+ <div class="fullwidth" id="token_expires_in" name="token_expires_in">
54
+ <%= tiny_account.token_expires_in %>
55
+ </div>
56
+ </div>
57
+ </div>
27
58
  </div>
28
- </div>
29
59
  </fieldset>
30
60
 
31
61
  <fieldset id="payment_methods" class="no-border-top">
@@ -64,20 +94,20 @@
64
94
  </div>
65
95
  <div class="col-12 col-md-3">
66
96
  <div class="field">
67
- <%= ship_form.label :name, "Nome da Logística", class: 'required' %>
68
- <%= ship_form.text_field :name, required: true, class:"fullwidth" %>
97
+ <%= ship_form.label :id_transportador, "ID Transportador", class: "required" %>
98
+ <%= ship_form.text_field :id_transportador, required: true, class:"fullwidth" %>
69
99
  </div>
70
100
  </div>
71
101
  <div class="col-12 col-md-3">
72
102
  <div class="field">
73
- <%= ship_form.label :service, "Serviço", class: 'required' %>
74
- <%= ship_form.text_field :service, required: true, class:"fullwidth" %>
103
+ <%= ship_form.label :id_forma_envio, "ID Forma de Envio", class: "required" %>
104
+ <%= ship_form.text_field :id_forma_envio, required: true, class:"fullwidth" %>
75
105
  </div>
76
106
  </div>
77
107
  <div class="col-12 col-md-3">
78
108
  <div class="field">
79
- <%= ship_form.label :company, "Nome Transportadora", class: 'required' %>
80
- <%= ship_form.text_field :company, required: true, class:"fullwidth" %>
109
+ <%= ship_form.label :id_forma_frete, "ID Forma de Frete", class: "required" %>
110
+ <%= ship_form.text_field :id_forma_frete, required: true, class:"fullwidth" %>
81
111
  </div>
82
112
  </div>
83
113
  </div>
@@ -90,8 +120,8 @@
90
120
  Vendedor padrão
91
121
  </legend>
92
122
  <div class="field">
93
- <%= form.label "default_seller[id]", "Vendedor Padrão", class: '' %>
94
- <%= form.select "default_seller[id]", @sellers, {selected: ::SolidusTiny::Seller.default&.id, include_blank: true }, { class: "custom-select fullwidth" } %>
123
+ <%= form.label :default_seller_id, "Vendedor Padrão", class: '' %>
124
+ <%= form.select :default_seller_id, @sellers, {selected: ::SolidusTiny::Seller.default&.id, include_blank: true }, { class: "custom-select fullwidth" } %>
95
125
  </div>
96
126
  </fieldset>
97
127
  <% end %>
@@ -0,0 +1,10 @@
1
+ <div class="field">
2
+ <div style="display: flex; align-items: center; margin-bottom: 6px">
3
+ <label style="margin-right: 5px; margin-bottom: 0" for="auth_url">URL de autorização</label>
4
+ <a target="_blank" href="<%= account.authorization_url %>">
5
+ <svg style="width: 18px; height: 18px; color: black" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
6
+ <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"></path></svg>
7
+ </a>
8
+ </div>
9
+ <input id="auth_url" class="fullwidth" value="<%= account.authorization_url %>">
10
+ </div>
@@ -13,35 +13,44 @@
13
13
 
14
14
  <div class="content-wrapper">
15
15
  <% @accounts.each do |account| %>
16
+ <%= render "link_auth", account: account %>
16
17
 
17
18
  <fieldset class="no-border-top">
18
19
  <legend>
19
20
  Dados da Conta
20
21
  </legend>
21
22
  <div class="row">
22
-
23
- <div class="col-12">
23
+ <div class="col-12 col-md-6">
24
+
24
25
  <div class="field">
25
- <%= label_tag :api_key, "API Key" %>
26
- <%= text_field_tag :api_key, account.api_key, class:"fullwidth", disabled: true %>
26
+ <%= label_tag :client_id, "Client ID" %>
27
+ <%= text_field_tag :client_id, account.client_id, class:"fullwidth", disabled: true %>
27
28
  </div>
28
- </div>
29
- <div class="col-md-6 col-12">
29
+
30
30
  <div class="field">
31
- <%= label_tag :stock_location, "Depósito" %>
32
- <%= text_field_tag :stock_location, account.stock_location, class:"fullwidth", disabled: true %>
31
+ <%= button_to "Atualizar vendedores", upsert_sellers_admin_solidus_tiny_accounts_path %>
33
32
  </div>
34
33
  </div>
35
- <div class="col-md-6 col-12">
34
+
35
+ <div class="col-12 col-md-6">
36
+
36
37
  <div class="field">
37
- <%= label_tag :operation_id, "ID Natureza de Operação" %>
38
- <%= text_field_tag :operation_id, account.operation_id, class:"fullwidth", disabled: true %>
38
+ <%= label_tag :redirect_url, "Redirect URL" %>
39
+ <%= text_field_tag :redirect_url, account.redirect_url, class:"fullwidth", disabled: true %>
40
+ </div>
41
+
42
+ <div class="field">
43
+ <%= label_tag :state, "State" %>
44
+ <%= text_field_tag :state, account.state, class:"fullwidth", disabled: true %>
39
45
  </div>
40
- </div>
41
46
 
42
- </div>
43
- <div class="field">
44
- <%= button_to "Atualizar vendedores", upsert_sellers_admin_solidus_tiny_accounts_path %>
47
+ <div class="field">
48
+ <%= label_tag :token_expires_in, "Token Expiration" %>
49
+ <div class="fullwidth" id="token_expires_in" name="token_expires_in">
50
+ <%= account.token_expires_in %>
51
+ </div>
52
+ </div>
53
+ </div>
45
54
  </div>
46
55
  </fieldset>
47
56
 
data/config/routes.rb CHANGED
@@ -10,6 +10,7 @@ Spree::Core::Engine.routes.draw do
10
10
  namespace :solidus_tiny do
11
11
  resources :accounts do
12
12
  post "upsert_sellers", on: :collection
13
+ get "authorize", on: :collection
13
14
  end
14
15
  resources :orders, only: [:update]
15
16
  end
@@ -0,0 +1,11 @@
1
+ class AddOauthColumnsToAccounts < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :solidus_tiny_accounts, :client_id, :string
4
+ add_column :solidus_tiny_accounts, :client_secret, :string
5
+ add_column :solidus_tiny_accounts, :access_token, :string
6
+ add_column :solidus_tiny_accounts, :refresh_token, :string
7
+ add_column :solidus_tiny_accounts, :token_expires_in, :datetime
8
+ add_column :solidus_tiny_accounts, :redirect_url, :string
9
+ add_column :solidus_tiny_accounts, :state, :string
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ class RenameShippingMethodsColumns < ActiveRecord::Migration[7.0]
2
+ def change
3
+ rename_column :solidus_tiny_shipping_methods, :company, :id_transportador
4
+ rename_column :solidus_tiny_shipping_methods, :name, :id_forma_envio
5
+ rename_column :solidus_tiny_shipping_methods, :service, :id_forma_frete
6
+ end
7
+ end
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  SolidusTiny.configure do |config|
2
+ config.order_tags = []
4
3
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  module SolidusTiny
4
4
  class Configuration
5
+ attr_accessor :order_tags
5
6
  end
6
7
 
7
8
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusTiny
4
- VERSION = "1.2.0"
4
+ VERSION = "2.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_tiny
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ulysses
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
11
+ date: 2026-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_brazilian_adaptations
@@ -57,12 +57,14 @@ files:
57
57
  - app/models/solidus_tiny/payment_method.rb
58
58
  - app/models/solidus_tiny/seller.rb
59
59
  - app/models/solidus_tiny/shipping_method.rb
60
+ - app/models/solidus_tiny/tiny_client.rb
60
61
  - app/models/spree/permission_sets/tiny_seller_update.rb
61
62
  - app/subscribers/solidus_tiny/subscriber.rb
62
63
  - app/views/spree/admin/orders/solidus_tiny/sellers/edit.html.erb
63
64
  - app/views/spree/admin/shared/_order_submenu.html.erb
64
65
  - app/views/spree/admin/shared/_order_summary.html.erb
65
66
  - app/views/spree/admin/solidus_tiny/accounts/_form.html.erb
67
+ - app/views/spree/admin/solidus_tiny/accounts/_link_auth.html.erb
66
68
  - app/views/spree/admin/solidus_tiny/accounts/edit.html.erb
67
69
  - app/views/spree/admin/solidus_tiny/accounts/index.html.erb
68
70
  - app/views/spree/admin/solidus_tiny/accounts/new.html.erb
@@ -75,6 +77,8 @@ files:
75
77
  - db/migrate/20240507121424_create_solidus_tiny_payment_methods.rb
76
78
  - db/migrate/20240507181649_add_tiny_order_id_to_spree_orders.rb
77
79
  - db/migrate/20240507190528_create_solidus_tiny_events.rb
80
+ - db/migrate/20260525185329_add_oauth_columns_to_accounts.rb
81
+ - db/migrate/20260527120536_rename_shipping_methods_columns.rb
78
82
  - lib/generators/solidus_tiny/install/install_generator.rb
79
83
  - lib/generators/solidus_tiny/install/templates/initializer.rb
80
84
  - lib/solidus_tiny.rb