open_mercato 0.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 +7 -0
- data/LICENSE +23 -0
- data/README.md +424 -0
- data/app/controllers/open_mercato/webhooks_controller.rb +46 -0
- data/app/jobs/open_mercato/webhook_job.rb +12 -0
- data/config/routes.rb +5 -0
- data/lib/generators/open_mercato/install/install_generator.rb +36 -0
- data/lib/generators/open_mercato/install/templates/initializer.rb.tt +21 -0
- data/lib/generators/open_mercato/install/templates/webhook_handlers.rb.tt +35 -0
- data/lib/open_mercato/client.rb +120 -0
- data/lib/open_mercato/collection.rb +21 -0
- data/lib/open_mercato/configuration.rb +32 -0
- data/lib/open_mercato/engine.rb +7 -0
- data/lib/open_mercato/error.rb +37 -0
- data/lib/open_mercato/resource.rb +57 -0
- data/lib/open_mercato/resources/attachments/library.rb +23 -0
- data/lib/open_mercato/resources/auth/api_key.rb +20 -0
- data/lib/open_mercato/resources/auth/user.rb +20 -0
- data/lib/open_mercato/resources/catalog/category.rb +21 -0
- data/lib/open_mercato/resources/catalog/offer.rb +23 -0
- data/lib/open_mercato/resources/catalog/price.rb +23 -0
- data/lib/open_mercato/resources/catalog/price_kind.rb +19 -0
- data/lib/open_mercato/resources/catalog/product.rb +23 -0
- data/lib/open_mercato/resources/catalog/tag.rb +18 -0
- data/lib/open_mercato/resources/catalog/variant.rb +25 -0
- data/lib/open_mercato/resources/customers/activity.rb +24 -0
- data/lib/open_mercato/resources/customers/address.rb +24 -0
- data/lib/open_mercato/resources/customers/comment.rb +19 -0
- data/lib/open_mercato/resources/customers/company.rb +23 -0
- data/lib/open_mercato/resources/customers/deal.rb +26 -0
- data/lib/open_mercato/resources/customers/person.rb +23 -0
- data/lib/open_mercato/resources/customers/tag.rb +18 -0
- data/lib/open_mercato/resources/dictionaries/dictionary.rb +19 -0
- data/lib/open_mercato/resources/dictionaries/entry.rb +44 -0
- data/lib/open_mercato/resources/notifications/notification.rb +20 -0
- data/lib/open_mercato/resources/sales/channel.rb +19 -0
- data/lib/open_mercato/resources/sales/dashboard/new_orders.rb +19 -0
- data/lib/open_mercato/resources/sales/dashboard/new_quotes.rb +19 -0
- data/lib/open_mercato/resources/sales/invoice.rb +28 -0
- data/lib/open_mercato/resources/sales/order.rb +26 -0
- data/lib/open_mercato/resources/sales/order_line.rb +24 -0
- data/lib/open_mercato/resources/sales/payment.rb +22 -0
- data/lib/open_mercato/resources/sales/payment_method.rb +19 -0
- data/lib/open_mercato/resources/sales/quote.rb +40 -0
- data/lib/open_mercato/resources/sales/shipment.rb +22 -0
- data/lib/open_mercato/resources/sales/shipping_method.rb +21 -0
- data/lib/open_mercato/resources/sales/tax_rate.rb +20 -0
- data/lib/open_mercato/resources/search/query.rb +23 -0
- data/lib/open_mercato/resources/translations/translation.rb +25 -0
- data/lib/open_mercato/resources/workflows/definition.rb +19 -0
- data/lib/open_mercato/resources/workflows/instance.rb +32 -0
- data/lib/open_mercato/resources/workflows/signal.rb +18 -0
- data/lib/open_mercato/resources/workflows/task.rb +33 -0
- data/lib/open_mercato/testing/fake_responses.rb +161 -0
- data/lib/open_mercato/testing/request_stubs.rb +50 -0
- data/lib/open_mercato/testing/webhook_helpers.rb +41 -0
- data/lib/open_mercato/testing.rb +19 -0
- data/lib/open_mercato/version.rb +5 -0
- data/lib/open_mercato/webhooks/event.rb +63 -0
- data/lib/open_mercato/webhooks/handler.rb +50 -0
- data/lib/open_mercato/webhooks/signature.rb +55 -0
- data/lib/open_mercato.rb +44 -0
- metadata +353 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Dictionaries
|
|
6
|
+
class Dictionary < Resource
|
|
7
|
+
api_path "/api/dictionaries"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :name, :string
|
|
11
|
+
attribute :slug, :string
|
|
12
|
+
attribute :description, :string
|
|
13
|
+
attribute :is_system, :boolean
|
|
14
|
+
attribute :created_at, :string
|
|
15
|
+
attribute :updated_at, :string
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Dictionaries
|
|
6
|
+
class Entry < Resource
|
|
7
|
+
api_path "/api/dictionaries"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :dictionary_id, :string
|
|
11
|
+
attribute :label, :string
|
|
12
|
+
attribute :value, :string
|
|
13
|
+
attribute :position, :integer
|
|
14
|
+
attribute :is_active, :boolean
|
|
15
|
+
attribute :created_at, :string
|
|
16
|
+
attribute :updated_at, :string
|
|
17
|
+
|
|
18
|
+
class << self
|
|
19
|
+
def list(dictionary_id, params = {})
|
|
20
|
+
response = OpenMercato.client.get("/api/dictionaries/#{dictionary_id}/entries", params)
|
|
21
|
+
Collection.new(response, self)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def find(dictionary_id, entry_id)
|
|
25
|
+
response = OpenMercato.client.get("/api/dictionaries/#{dictionary_id}/entries/#{entry_id}")
|
|
26
|
+
new(response)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create(dictionary_id, attributes = {})
|
|
30
|
+
OpenMercato.client.post("/api/dictionaries/#{dictionary_id}/entries", attributes)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def update(dictionary_id, entry_id, attributes = {})
|
|
34
|
+
OpenMercato.client.put("/api/dictionaries/#{dictionary_id}/entries", attributes.merge(id: entry_id))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def destroy(dictionary_id, entry_id)
|
|
38
|
+
OpenMercato.client.delete("/api/dictionaries/#{dictionary_id}/entries", id: entry_id)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Notifications
|
|
6
|
+
class Notification < Resource
|
|
7
|
+
api_path "/api/notifications"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :notification_type, :string
|
|
11
|
+
attribute :title, :string
|
|
12
|
+
attribute :body, :string
|
|
13
|
+
attribute :is_read, :boolean
|
|
14
|
+
attribute :recipient_id, :string
|
|
15
|
+
attribute :created_at, :string
|
|
16
|
+
attribute :updated_at, :string
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class Channel < Resource
|
|
7
|
+
api_path "/api/sales/channels"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :name, :string
|
|
11
|
+
attribute :slug, :string
|
|
12
|
+
attribute :is_active, :boolean
|
|
13
|
+
attribute :description, :string
|
|
14
|
+
attribute :created_at, :string
|
|
15
|
+
attribute :updated_at, :string
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
module Dashboard
|
|
7
|
+
class NewOrders
|
|
8
|
+
class << self
|
|
9
|
+
# Params: limit (1-20), date_period (last24h|last7d|last30d|custom),
|
|
10
|
+
# custom_from, custom_to (ISO strings when date_period=custom)
|
|
11
|
+
def list(params = {})
|
|
12
|
+
OpenMercato.client.get("/api/sales/dashboard/widgets/new-orders", params)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
module Dashboard
|
|
7
|
+
class NewQuotes
|
|
8
|
+
class << self
|
|
9
|
+
# Params: limit (1-20), date_period (last24h|last7d|last30d|custom),
|
|
10
|
+
# custom_from, custom_to (ISO strings when date_period=custom)
|
|
11
|
+
def list(params = {})
|
|
12
|
+
OpenMercato.client.get("/api/sales/dashboard/widgets/new-quotes", params)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class Invoice < Resource
|
|
7
|
+
api_path "/api/sales/invoices"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :invoice_number, :string
|
|
11
|
+
attribute :order_id, :string
|
|
12
|
+
attribute :status, :string
|
|
13
|
+
attribute :customer_id, :string
|
|
14
|
+
attribute :currency_code, :string
|
|
15
|
+
attribute :subtotal, :string
|
|
16
|
+
attribute :tax_total, :string
|
|
17
|
+
attribute :discount_total, :string
|
|
18
|
+
attribute :total, :string
|
|
19
|
+
attribute :issued_at, :string
|
|
20
|
+
attribute :due_date, :string
|
|
21
|
+
attribute :paid_at, :string
|
|
22
|
+
attribute :notes, :string
|
|
23
|
+
attribute :created_at, :string
|
|
24
|
+
attribute :updated_at, :string
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class Order < Resource
|
|
7
|
+
api_path "/api/sales/orders"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :order_number, :string
|
|
11
|
+
attribute :status, :string
|
|
12
|
+
attribute :customer_id, :string
|
|
13
|
+
attribute :channel_id, :string
|
|
14
|
+
attribute :currency_code, :string
|
|
15
|
+
attribute :subtotal, :string
|
|
16
|
+
attribute :tax_total, :string
|
|
17
|
+
attribute :discount_total, :string
|
|
18
|
+
attribute :total, :string
|
|
19
|
+
attribute :notes, :string
|
|
20
|
+
attribute :placed_at, :string
|
|
21
|
+
attribute :created_at, :string
|
|
22
|
+
attribute :updated_at, :string
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class OrderLine < Resource
|
|
7
|
+
api_path "/api/sales/order-lines"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :order_id, :string
|
|
11
|
+
attribute :variant_id, :string
|
|
12
|
+
attribute :quantity, :integer
|
|
13
|
+
attribute :unit_price, :string
|
|
14
|
+
attribute :tax_amount, :string
|
|
15
|
+
attribute :discount_amount, :string
|
|
16
|
+
attribute :total, :string
|
|
17
|
+
attribute :sku, :string
|
|
18
|
+
attribute :title, :string
|
|
19
|
+
attribute :created_at, :string
|
|
20
|
+
attribute :updated_at, :string
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class Payment < Resource
|
|
7
|
+
api_path "/api/sales/payments"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :order_id, :string
|
|
11
|
+
attribute :amount, :string
|
|
12
|
+
attribute :currency_code, :string
|
|
13
|
+
attribute :status, :string
|
|
14
|
+
attribute :payment_method_id, :string
|
|
15
|
+
attribute :reference, :string
|
|
16
|
+
attribute :paid_at, :string
|
|
17
|
+
attribute :created_at, :string
|
|
18
|
+
attribute :updated_at, :string
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class PaymentMethod < Resource
|
|
7
|
+
api_path "/api/sales/payment-methods"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :name, :string
|
|
11
|
+
attribute :slug, :string
|
|
12
|
+
attribute :is_active, :boolean
|
|
13
|
+
attribute :description, :string
|
|
14
|
+
attribute :created_at, :string
|
|
15
|
+
attribute :updated_at, :string
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class Quote < Resource
|
|
7
|
+
api_path "/api/sales/quotes"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :quote_number, :string
|
|
11
|
+
attribute :status, :string
|
|
12
|
+
attribute :customer_id, :string
|
|
13
|
+
attribute :channel_id, :string
|
|
14
|
+
attribute :currency_code, :string
|
|
15
|
+
attribute :subtotal, :string
|
|
16
|
+
attribute :tax_total, :string
|
|
17
|
+
attribute :discount_total, :string
|
|
18
|
+
attribute :total, :string
|
|
19
|
+
attribute :valid_until, :string
|
|
20
|
+
attribute :notes, :string
|
|
21
|
+
attribute :created_at, :string
|
|
22
|
+
attribute :updated_at, :string
|
|
23
|
+
|
|
24
|
+
class << self
|
|
25
|
+
def accept(id)
|
|
26
|
+
OpenMercato.client.post("#{api_path}/accept", id: id)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def convert_to_order(id)
|
|
30
|
+
OpenMercato.client.post("#{api_path}/convert", id: id)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def send_quote(id)
|
|
34
|
+
OpenMercato.client.post("#{api_path}/send", id: id)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class Shipment < Resource
|
|
7
|
+
api_path "/api/sales/shipments"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :order_id, :string
|
|
11
|
+
attribute :status, :string
|
|
12
|
+
attribute :shipping_method_id, :string
|
|
13
|
+
attribute :tracking_number, :string
|
|
14
|
+
attribute :tracking_url, :string
|
|
15
|
+
attribute :shipped_at, :string
|
|
16
|
+
attribute :delivered_at, :string
|
|
17
|
+
attribute :created_at, :string
|
|
18
|
+
attribute :updated_at, :string
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class ShippingMethod < Resource
|
|
7
|
+
api_path "/api/sales/shipping-methods"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :name, :string
|
|
11
|
+
attribute :slug, :string
|
|
12
|
+
attribute :price, :string
|
|
13
|
+
attribute :currency_code, :string
|
|
14
|
+
attribute :is_active, :boolean
|
|
15
|
+
attribute :description, :string
|
|
16
|
+
attribute :created_at, :string
|
|
17
|
+
attribute :updated_at, :string
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Sales
|
|
6
|
+
class TaxRate < Resource
|
|
7
|
+
api_path "/api/sales/tax-rates"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :name, :string
|
|
11
|
+
attribute :rate, :string
|
|
12
|
+
attribute :is_active, :boolean
|
|
13
|
+
attribute :country_code, :string
|
|
14
|
+
attribute :description, :string
|
|
15
|
+
attribute :created_at, :string
|
|
16
|
+
attribute :updated_at, :string
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Search
|
|
6
|
+
class Query
|
|
7
|
+
class << self
|
|
8
|
+
def search(query, params = {})
|
|
9
|
+
OpenMercato.client.get("/api/search/search", params.merge(q: query))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def global(query, params = {})
|
|
13
|
+
OpenMercato.client.get("/api/search/search/global", params.merge(q: query))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def reindex(params = {})
|
|
17
|
+
OpenMercato.client.post("/api/search/reindex", params)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Translations
|
|
6
|
+
# Manages per-entity translation records.
|
|
7
|
+
# Path pattern: /api/translations/:entity_type/:entity_id
|
|
8
|
+
class Translation
|
|
9
|
+
class << self
|
|
10
|
+
def find(entity_type, entity_id)
|
|
11
|
+
OpenMercato.client.get("/api/translations/#{entity_type}/#{entity_id}")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def set_translations(entity_type, entity_id, translations:)
|
|
15
|
+
OpenMercato.client.put("/api/translations/#{entity_type}/#{entity_id}", translations: translations)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def destroy(entity_type, entity_id)
|
|
19
|
+
OpenMercato.client.delete("/api/translations/#{entity_type}/#{entity_id}")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Workflows
|
|
6
|
+
class Definition < Resource
|
|
7
|
+
api_path "/api/workflows/definitions"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :name, :string
|
|
11
|
+
attribute :description, :string
|
|
12
|
+
attribute :is_active, :boolean
|
|
13
|
+
attribute :trigger_event, :string
|
|
14
|
+
attribute :created_at, :string
|
|
15
|
+
attribute :updated_at, :string
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Workflows
|
|
6
|
+
class Instance < Resource
|
|
7
|
+
api_path "/api/workflows/instances"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :definition_id, :string
|
|
11
|
+
attribute :status, :string
|
|
12
|
+
attribute :current_step, :string
|
|
13
|
+
attribute :started_at, :string
|
|
14
|
+
attribute :completed_at, :string
|
|
15
|
+
attribute :created_at, :string
|
|
16
|
+
attribute :updated_at, :string
|
|
17
|
+
|
|
18
|
+
class << self
|
|
19
|
+
def signal(id, signal_name, payload = {})
|
|
20
|
+
OpenMercato.client.post("#{api_path}/#{id}/signal", { signal: signal_name }.merge(payload))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def advance(id, to_step_id: nil, trigger_data: {}, context_updates: {})
|
|
24
|
+
payload = { triggerData: trigger_data, contextUpdates: context_updates }
|
|
25
|
+
payload[:toStepId] = to_step_id if to_step_id
|
|
26
|
+
OpenMercato.client.post("#{api_path}/#{id}/advance", payload)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Workflows
|
|
6
|
+
class Signal
|
|
7
|
+
class << self
|
|
8
|
+
def send_signal(correlation_key:, signal_name:, payload: {})
|
|
9
|
+
OpenMercato.client.post(
|
|
10
|
+
"/api/workflows/signals",
|
|
11
|
+
{ correlationKey: correlation_key, signalName: signal_name, payload: payload }
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenMercato
|
|
4
|
+
module Resources
|
|
5
|
+
module Workflows
|
|
6
|
+
class Task < Resource
|
|
7
|
+
api_path "/api/workflows/tasks"
|
|
8
|
+
|
|
9
|
+
attribute :id, :string
|
|
10
|
+
attribute :title, :string
|
|
11
|
+
attribute :description, :string
|
|
12
|
+
attribute :status, :string
|
|
13
|
+
attribute :assigned_to, :string
|
|
14
|
+
attribute :workflow_instance_id, :string
|
|
15
|
+
attribute :due_date, :string
|
|
16
|
+
attribute :created_at, :string
|
|
17
|
+
attribute :updated_at, :string
|
|
18
|
+
|
|
19
|
+
class << self
|
|
20
|
+
def claim(id)
|
|
21
|
+
OpenMercato.client.post("#{api_path}/#{id}/claim")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def complete(id, form_data: {}, comments: nil)
|
|
25
|
+
payload = { formData: form_data }
|
|
26
|
+
payload[:comments] = comments if comments
|
|
27
|
+
OpenMercato.client.post("#{api_path}/#{id}/complete", payload)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|