solidus_tiny 1.0.1 → 2.0.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 +4 -4
- data/README.md +0 -58
- data/app/controllers/spree/admin/solidus_tiny/accounts_controller.rb +14 -4
- data/app/models/solidus_tiny/account.rb +14 -0
- data/app/models/solidus_tiny/order.rb +114 -75
- data/app/models/solidus_tiny/seller.rb +17 -12
- data/app/models/solidus_tiny/shipping_method.rb +3 -3
- data/app/models/solidus_tiny/tiny_client.rb +34 -0
- data/app/views/spree/admin/solidus_tiny/accounts/_form.html.erb +60 -30
- data/app/views/spree/admin/solidus_tiny/accounts/_link_auth.html.erb +10 -0
- data/app/views/spree/admin/solidus_tiny/accounts/index.html.erb +24 -15
- data/config/routes.rb +1 -0
- data/db/migrate/20260525185329_add_oauth_columns_to_accounts.rb +11 -0
- data/db/migrate/20260527120536_rename_shipping_methods_columns.rb +7 -0
- data/lib/solidus_tiny/engine.rb +0 -13
- data/lib/solidus_tiny/version.rb +1 -1
- metadata +14 -85
- data/.circleci/config.yml +0 -53
- data/.gem_release.yml +0 -5
- data/.github/stale.yml +0 -1
- data/.github_changelog_generator +0 -2
- data/.gitignore +0 -21
- data/.rspec +0 -2
- data/.rubocop.yml +0 -5
- data/CHANGELOG.md +0 -3
- data/Gemfile +0 -48
- data/LICENSE +0 -26
- data/Rakefile +0 -7
- data/bin/console +0 -17
- data/bin/rails +0 -7
- data/bin/rails-engine +0 -13
- data/bin/rails-sandbox +0 -16
- data/bin/rake +0 -7
- data/bin/sandbox +0 -76
- data/bin/setup +0 -8
- data/config/locales/en.yml +0 -5
- data/lib/solidus_tiny/testing_support/factories.rb +0 -4
- data/solidus_tiny.gemspec +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff31687be56d235bc95e5be92334ef0667f7630b924e71b922be1eeca09a73e8
|
|
4
|
+
data.tar.gz: aa3318f70139e1c7848537035a8a0eaf7b47c0a246d7678cbeb9a5e19693eec8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95c23c42156e43265026eafe4aa43404719b5fff1cfdb151bb86527a288b1ecde914b4dd9c7fa7b002fea8f54c71e6fccb884f5640d16dbcc53d15042b3ab4c1
|
|
7
|
+
data.tar.gz: 5c7d251ef8f25e2961c90ddb8dee9b451c66a8b7666c7a3cdbde48323f14285e5cdf61c00599aec02e78f4d3d3654fa3bcf56e3a9a01a459f42e9d965c92507a
|
data/README.md
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
# Solidus Tiny
|
|
2
2
|
|
|
3
|
-
[](https://circleci.com/gh/solidusio-contrib/solidus_tiny)
|
|
4
|
-
[](https://codecov.io/gh/solidusio-contrib/solidus_tiny)
|
|
5
|
-
|
|
6
|
-
<!-- Explain what your extension does. -->
|
|
7
|
-
|
|
8
3
|
## Installation
|
|
9
4
|
|
|
10
5
|
Add solidus_tiny to your Gemfile:
|
|
@@ -18,56 +13,3 @@ Bundle your dependencies and run the installation generator:
|
|
|
18
13
|
```shell
|
|
19
14
|
bin/rails generate solidus_tiny:install
|
|
20
15
|
```
|
|
21
|
-
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
|
-
<!-- Explain how to use your extension once it's been installed. -->
|
|
25
|
-
|
|
26
|
-
## Development
|
|
27
|
-
|
|
28
|
-
### Testing the extension
|
|
29
|
-
|
|
30
|
-
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
|
|
31
|
-
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
|
|
32
|
-
`bin/rake extension:test_app`.
|
|
33
|
-
|
|
34
|
-
```shell
|
|
35
|
-
bin/rake
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
|
|
39
|
-
|
|
40
|
-
```shell
|
|
41
|
-
bundle exec rubocop
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
When testing your application's integration with this extension you may use its factories.
|
|
45
|
-
You can load Solidus core factories along with this extension's factories using this statement:
|
|
46
|
-
|
|
47
|
-
```ruby
|
|
48
|
-
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusTiny::Engine)
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Running the sandbox
|
|
52
|
-
|
|
53
|
-
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
|
|
54
|
-
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
|
|
55
|
-
`sandbox/bin/rails`.
|
|
56
|
-
|
|
57
|
-
Here's an example:
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
$ bin/rails server
|
|
61
|
-
=> Booting Puma
|
|
62
|
-
=> Rails 6.0.2.1 application starting in development
|
|
63
|
-
* Listening on tcp://127.0.0.1:3000
|
|
64
|
-
Use Ctrl-C to stop
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Releasing new versions
|
|
68
|
-
|
|
69
|
-
Please refer to the [dedicated page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) in the Solidus wiki.
|
|
70
|
-
|
|
71
|
-
## License
|
|
72
|
-
|
|
73
|
-
Copyright (c) 2024 ulysses, released under the New BSD License.
|
|
@@ -43,7 +43,7 @@ module Spree
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def update
|
|
46
|
-
@tiny_account.sellers.find_by(seller_params[:
|
|
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, :
|
|
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(
|
|
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,74 @@
|
|
|
1
1
|
module SolidusTiny
|
|
2
2
|
class Order
|
|
3
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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)
|
|
46
37
|
end
|
|
47
38
|
|
|
48
|
-
def
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
def upsert_contact
|
|
40
|
+
search_contato = @client.find_contact_by_document(@order.tax_id).itens
|
|
41
|
+
contact_id = if search_contato.any?
|
|
42
|
+
@client.update_contact(
|
|
43
|
+
id: search_contato[0].id,
|
|
44
|
+
nome: @order.ship_address.name,
|
|
45
|
+
tipo_pessoa: @order.tax_id.length > 14 ? "J" : "F",
|
|
46
|
+
cpf_cnpj: @order.tax_id,
|
|
47
|
+
**build_customer_infos
|
|
48
|
+
)
|
|
49
|
+
search_contato[0].id
|
|
50
|
+
else
|
|
51
|
+
response = @client.create_contact(
|
|
52
|
+
nome: @order.ship_address.name,
|
|
53
|
+
tipo_pessoa: @order.tax_id.length > 14 ? "J" : "F",
|
|
54
|
+
cpf_cnpj: @order.tax_id,
|
|
55
|
+
**build_customer_infos
|
|
56
|
+
)
|
|
57
|
+
response.id
|
|
58
|
+
end
|
|
59
|
+
@client.get_contact(contact_id)
|
|
64
60
|
end
|
|
65
61
|
|
|
66
|
-
def
|
|
62
|
+
def build_tiny_items
|
|
67
63
|
@order.line_items.map do |item|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
api_product = @client.get_product_by_sku(item.sku).itens
|
|
65
|
+
raise "Produto com SKU #{item.sku} não encontrado no Tiny" if api_product.blank?
|
|
66
|
+
TinyErpApi::Item.new(
|
|
67
|
+
id_produto: api_product[0].id,
|
|
68
|
+
tipo: "P",
|
|
69
|
+
quantidade: item.quantity,
|
|
70
|
+
valor_unitario: item.price
|
|
71
|
+
)
|
|
75
72
|
end
|
|
76
73
|
end
|
|
77
74
|
|
|
@@ -79,26 +76,48 @@ module SolidusTiny
|
|
|
79
76
|
@order.solidus_tiny_seller_id ? @account.sellers.find(@order.solidus_tiny_seller_id).external_id : SolidusTiny::Seller.default.external_id
|
|
80
77
|
end
|
|
81
78
|
|
|
82
|
-
def
|
|
83
|
-
|
|
79
|
+
def build_tiny_address
|
|
80
|
+
ship_address = @order.ship_address
|
|
81
|
+
TinyErpApi::Address.new(
|
|
82
|
+
endereco: ship_address.address1,
|
|
83
|
+
endereco_numero: ship_address.number,
|
|
84
|
+
complemento: ship_address.address2,
|
|
85
|
+
bairro: ship_address.district,
|
|
86
|
+
municipio: ship_address.city,
|
|
87
|
+
cep: ship_address.zipcode,
|
|
88
|
+
uf: ship_address.state.abbr,
|
|
89
|
+
fone: ship_address.phone,
|
|
90
|
+
nome_destinatario: ship_address.name,
|
|
91
|
+
cpf_cnpj: @order.tax_id,
|
|
92
|
+
tipo_pessoa: @order.tax_id.length > 14 ? "J" : "F"
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def build_tiny_shipment
|
|
97
|
+
selected_shipping_method = @account
|
|
98
|
+
.shipping_methods
|
|
99
|
+
.find_by(spree_shipping_method_id: @order.shipments.last.shipping_method.id)
|
|
100
|
+
TinyErpApi::Shipment.new(
|
|
101
|
+
id_transportador: selected_shipping_method.id_transportador,
|
|
102
|
+
id_forma_envio: selected_shipping_method.id_forma_envio,
|
|
103
|
+
id_forma_frete: selected_shipping_method.id_forma_frete
|
|
104
|
+
)
|
|
84
105
|
end
|
|
85
106
|
|
|
86
|
-
def
|
|
107
|
+
def id_forma_recebimento
|
|
87
108
|
spree_payment = @order.payments.valid.last
|
|
88
|
-
|
|
109
|
+
@account.payment_methods.find_by(spree_payment_method_id: spree_payment.payment_method_id).alias
|
|
89
110
|
end
|
|
90
111
|
|
|
91
|
-
def
|
|
112
|
+
def build_tiny_installments
|
|
92
113
|
parcelas = @order.payments.last.source.try(:installments) || 1
|
|
93
114
|
valor_parcela = @order.total.to_f / parcelas
|
|
94
115
|
1.upto(parcelas).map do |parcela|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
}
|
|
116
|
+
TinyErpApi::Installment.new(
|
|
117
|
+
data: (@order.completed_at + parcela.months).strftime("%Y-%m-%d"),
|
|
118
|
+
valor: valor_parcela,
|
|
119
|
+
id_forma_recebimento: id_forma_recebimento
|
|
120
|
+
)
|
|
102
121
|
end
|
|
103
122
|
end
|
|
104
123
|
|
|
@@ -125,5 +144,25 @@ module SolidusTiny
|
|
|
125
144
|
"Link para o pedido: #{@order.store.url}/pedidos/#{@order.number}"
|
|
126
145
|
end
|
|
127
146
|
|
|
147
|
+
def build_customer_infos
|
|
148
|
+
ship_address = @order.ship_address
|
|
149
|
+
{
|
|
150
|
+
email: @order.email,
|
|
151
|
+
celular: ship_address.phone,
|
|
152
|
+
endereco: ship_address.address1,
|
|
153
|
+
endereco_numero: ship_address.number,
|
|
154
|
+
endereco_complemento: ship_address.address2,
|
|
155
|
+
endereco_bairro: ship_address.district,
|
|
156
|
+
endereco_cep: ship_address.zipcode,
|
|
157
|
+
endereco_municipio: ship_address.city,
|
|
158
|
+
endereco_uf: ship_address.state.abbr,
|
|
159
|
+
endereco_pais: "Brasil",
|
|
160
|
+
}
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Sobreescreva esse método para customizar as observações internas do pedido no Tiny
|
|
164
|
+
def build_observacoes
|
|
165
|
+
"Pedido realizado no e-commerce #{build_order_url}"
|
|
166
|
+
end
|
|
128
167
|
end
|
|
129
168
|
end
|
|
@@ -8,19 +8,24 @@ module SolidusTiny
|
|
|
8
8
|
after_save :falsify_all_others
|
|
9
9
|
|
|
10
10
|
def self.upsert_sellers account
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 :
|
|
4
|
-
validates :
|
|
5
|
-
validates :
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<%= form.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<%= form.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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 :
|
|
68
|
-
<%= ship_form.text_field :
|
|
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 :
|
|
74
|
-
<%= ship_form.text_field :
|
|
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 :
|
|
80
|
-
<%= ship_form.text_field :
|
|
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
|
|
94
|
-
<%= form.select
|
|
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
|
-
|
|
23
|
+
<div class="col-12 col-md-6">
|
|
24
|
+
|
|
24
25
|
<div class="field">
|
|
25
|
-
<%= label_tag :
|
|
26
|
-
<%= text_field_tag :
|
|
26
|
+
<%= label_tag :client_id, "Client ID" %>
|
|
27
|
+
<%= text_field_tag :client_id, account.client_id, class:"fullwidth", disabled: true %>
|
|
27
28
|
</div>
|
|
28
|
-
|
|
29
|
-
<div class="col-md-6 col-12">
|
|
29
|
+
|
|
30
30
|
<div class="field">
|
|
31
|
-
<%=
|
|
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
|
-
|
|
34
|
+
|
|
35
|
+
<div class="col-12 col-md-6">
|
|
36
|
+
|
|
36
37
|
<div class="field">
|
|
37
|
-
<%= label_tag :
|
|
38
|
-
<%= text_field_tag :
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|