conexa 0.0.8 → 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 +4 -4
- data/CHANGELOG.md +64 -1
- data/Gemfile.lock +1 -1
- data/README.md +211 -56
- data/README_pt-BR.md +116 -12
- data/REFERENCE.md +138 -14
- data/lib/conexa/authenticator.rb +2 -0
- data/lib/conexa/configuration.rb +2 -0
- data/lib/conexa/core_ext.rb +11 -6
- data/lib/conexa/errors.rb +5 -3
- data/lib/conexa/model.rb +64 -28
- data/lib/conexa/object.rb +12 -17
- data/lib/conexa/{order_commom.rb → order_common.rb} +5 -5
- data/lib/conexa/request.rb +9 -8
- data/lib/conexa/resources/account.rb +33 -0
- data/lib/conexa/resources/bill.rb +3 -1
- data/lib/conexa/resources/bill_category.rb +33 -0
- data/lib/conexa/resources/bill_subcategory.rb +35 -0
- data/lib/conexa/resources/charge.rb +1 -1
- data/lib/conexa/resources/company.rb +2 -0
- data/lib/conexa/resources/cost_center.rb +33 -0
- data/lib/conexa/resources/credit_card.rb +2 -0
- data/lib/conexa/resources/customer.rb +3 -3
- data/lib/conexa/resources/invoicing_method.rb +2 -0
- data/lib/conexa/resources/legal_person.rb +2 -0
- data/lib/conexa/resources/pagination.rb +2 -0
- data/lib/conexa/resources/payment_method.rb +33 -0
- data/lib/conexa/resources/person.rb +2 -0
- data/lib/conexa/resources/plan.rb +2 -0
- data/lib/conexa/resources/product.rb +28 -4
- data/lib/conexa/resources/receiving_method.rb +55 -0
- data/lib/conexa/resources/recurring_sale.rb +2 -0
- data/lib/conexa/resources/result.rb +32 -5
- data/lib/conexa/resources/room_booking.rb +87 -0
- data/lib/conexa/resources/sale.rb +1 -1
- data/lib/conexa/resources/service_category.rb +33 -0
- data/lib/conexa/resources/supplier.rb +24 -1
- data/lib/conexa/token_manager.rb +3 -1
- data/lib/conexa/util.rb +37 -50
- data/lib/conexa/version.rb +1 -1
- data/lib/conexa.rb +1 -1
- metadata +10 -2
|
@@ -8,7 +8,7 @@ module Conexa
|
|
|
8
8
|
# charge.status # => "pending"
|
|
9
9
|
#
|
|
10
10
|
# @example List charges
|
|
11
|
-
# charges = Conexa::Charge.all(customer_id: [127], status: 'pending')
|
|
11
|
+
# charges = Conexa::Charge.all(customer_id: [127], status: 'pending', limit: 50)
|
|
12
12
|
#
|
|
13
13
|
# @example Settle (pay) a charge
|
|
14
14
|
# Conexa::Charge.settle(789)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conexa
|
|
4
|
+
# CostCenter resource (Centro de Custo)
|
|
5
|
+
#
|
|
6
|
+
# @example Find a cost center
|
|
7
|
+
# center = Conexa::CostCenter.find(11)
|
|
8
|
+
# center.name # => "Marketing"
|
|
9
|
+
#
|
|
10
|
+
# @example List cost centers
|
|
11
|
+
# centers = Conexa::CostCenter.all(limit: 50)
|
|
12
|
+
#
|
|
13
|
+
# @!attribute [r] cost_center_id
|
|
14
|
+
# @return [Integer] Cost center ID (also accessible as #id)
|
|
15
|
+
# @!attribute [r] name
|
|
16
|
+
# @return [String] Cost center name
|
|
17
|
+
# @!attribute [r] is_active
|
|
18
|
+
# @return [Boolean] Whether the cost center is active
|
|
19
|
+
#
|
|
20
|
+
class CostCenter < Model
|
|
21
|
+
primary_key_attribute :cost_center_id
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
def url(*params)
|
|
25
|
+
["/costCenters", *params].join '/'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def show_url(*params)
|
|
29
|
+
["/costCenter", *params].join '/'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -76,21 +76,21 @@ module Conexa
|
|
|
76
76
|
# @param customer_id [Integer] Customer ID
|
|
77
77
|
# @return [Result] List of persons
|
|
78
78
|
def persons(customer_id)
|
|
79
|
-
Conexa::Person.all(customer_id: customer_id)
|
|
79
|
+
Conexa::Person.all(customer_id: customer_id, limit: 100)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
# List contracts for a customer
|
|
83
83
|
# @param customer_id [Integer] Customer ID
|
|
84
84
|
# @return [Result] List of contracts
|
|
85
85
|
def contracts(customer_id)
|
|
86
|
-
Conexa::Contract.all(customer_id: [customer_id])
|
|
86
|
+
Conexa::Contract.all(customer_id: [customer_id], limit: 100)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# List charges for a customer
|
|
90
90
|
# @param customer_id [Integer] Customer ID
|
|
91
91
|
# @return [Result] List of charges
|
|
92
92
|
def charges(customer_id)
|
|
93
|
-
Conexa::Charge.all(customer_id: [customer_id])
|
|
93
|
+
Conexa::Charge.all(customer_id: [customer_id], limit: 100)
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conexa
|
|
4
|
+
# PaymentMethod resource (Meio de Pagamento)
|
|
5
|
+
#
|
|
6
|
+
# @example Find a payment method
|
|
7
|
+
# method = Conexa::PaymentMethod.find(2)
|
|
8
|
+
# method.name # => "Boleto"
|
|
9
|
+
#
|
|
10
|
+
# @example List payment methods
|
|
11
|
+
# methods = Conexa::PaymentMethod.all(limit: 50)
|
|
12
|
+
#
|
|
13
|
+
# @!attribute [r] payment_method_id
|
|
14
|
+
# @return [Integer] Payment method ID (also accessible as #id)
|
|
15
|
+
# @!attribute [r] name
|
|
16
|
+
# @return [String] Name
|
|
17
|
+
# @!attribute [r] is_active
|
|
18
|
+
# @return [Boolean] Whether the payment method is active
|
|
19
|
+
#
|
|
20
|
+
class PaymentMethod < Model
|
|
21
|
+
primary_key_attribute :payment_method_id
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
def url(*params)
|
|
25
|
+
["/paymentMethods", *params].join '/'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def show_url(*params)
|
|
29
|
+
["/paymentMethod", *params].join '/'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -1,7 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Conexa
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
# Product resource (read-only for listing/retrieving)
|
|
5
|
+
#
|
|
6
|
+
# The new API v2 also supports POST /product and DELETE /product/:id.
|
|
7
|
+
#
|
|
8
|
+
# @example Find a product
|
|
9
|
+
# product = Conexa::Product.find(100)
|
|
10
|
+
# product.name # => "Mensalidade"
|
|
11
|
+
#
|
|
12
|
+
# @example List products
|
|
13
|
+
# products = Conexa::Product.all(company_id: [3], limit: 50)
|
|
14
|
+
#
|
|
15
|
+
# @example Create a product
|
|
16
|
+
# product = Conexa::Product.create(name: 'Novo Produto', company_id: 3)
|
|
17
|
+
#
|
|
18
|
+
# @example Delete a product
|
|
19
|
+
# Conexa::Product.destroy(100)
|
|
20
|
+
#
|
|
21
|
+
# @!attribute [r] product_id
|
|
22
|
+
# @return [Integer] Product ID (also accessible as #id)
|
|
23
|
+
# @!attribute [r] name
|
|
24
|
+
# @return [String] Product name
|
|
25
|
+
# @!attribute [r] is_active
|
|
26
|
+
# @return [Boolean] Whether the product is active
|
|
27
|
+
#
|
|
28
|
+
class Product < Model
|
|
29
|
+
primary_key_attribute :product_id
|
|
6
30
|
end
|
|
7
31
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conexa
|
|
4
|
+
# ReceivingMethod resource (Meio de Recebimento)
|
|
5
|
+
#
|
|
6
|
+
# @example Find a receiving method
|
|
7
|
+
# method = Conexa::ReceivingMethod.find(11)
|
|
8
|
+
# method.name # => "Cartão de Crédito"
|
|
9
|
+
#
|
|
10
|
+
# @example List receiving methods
|
|
11
|
+
# methods = Conexa::ReceivingMethod.all(limit: 50)
|
|
12
|
+
#
|
|
13
|
+
# @!attribute [r] receiving_method_id
|
|
14
|
+
# @return [Integer] Receiving method ID (also accessible as #id)
|
|
15
|
+
# @!attribute [r] name
|
|
16
|
+
# @return [String] Name
|
|
17
|
+
# @!attribute [r] max_installments
|
|
18
|
+
# @return [Integer] Maximum number of installments
|
|
19
|
+
# @!attribute [r] credit_days
|
|
20
|
+
# @return [Integer] Days until credit
|
|
21
|
+
# @!attribute [r] is_installment_fee
|
|
22
|
+
# @return [Boolean] Whether fee is per installment
|
|
23
|
+
# @!attribute [r] transaction_fee
|
|
24
|
+
# @return [Float] Fee per transaction
|
|
25
|
+
# @!attribute [r] transaction_rate
|
|
26
|
+
# @return [Float] Rate percentage per transaction
|
|
27
|
+
# @!attribute [r] account_id
|
|
28
|
+
# @return [Integer, nil] Associated account ID
|
|
29
|
+
# @!attribute [r] cost_center_id
|
|
30
|
+
# @return [Integer, nil] Cost center ID
|
|
31
|
+
# @!attribute [r] bill_category_id
|
|
32
|
+
# @return [Integer, nil] Bill category ID
|
|
33
|
+
# @!attribute [r] bill_subcategory_id
|
|
34
|
+
# @return [Integer, nil] Bill subcategory ID
|
|
35
|
+
# @!attribute [r] payment_method_id
|
|
36
|
+
# @return [Integer, nil] Payment method ID
|
|
37
|
+
# @!attribute [r] supplier_id
|
|
38
|
+
# @return [Integer, nil] Supplier ID
|
|
39
|
+
# @!attribute [r] is_active
|
|
40
|
+
# @return [Boolean] Whether the receiving method is active
|
|
41
|
+
#
|
|
42
|
+
class ReceivingMethod < Model
|
|
43
|
+
primary_key_attribute :receiving_method_id
|
|
44
|
+
|
|
45
|
+
class << self
|
|
46
|
+
def url(*params)
|
|
47
|
+
["/receivingMethods", *params].join '/'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def show_url(*params)
|
|
51
|
+
["/receivingMethod", *params].join '/'
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Conexa
|
|
2
4
|
class Result < ConexaObject
|
|
3
5
|
|
|
@@ -16,10 +18,31 @@ module Conexa
|
|
|
16
18
|
@attributes["pagination"]
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
+
def has_next?
|
|
22
|
+
pagination && pagination.has_next == true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def next_page
|
|
26
|
+
raise StopIteration, "No more pages" unless has_next?
|
|
27
|
+
raise "No query context available for next_page" unless @query_context
|
|
28
|
+
|
|
29
|
+
resource_class = @query_context[:resource_class]
|
|
30
|
+
next_params = Marshal.load(Marshal.dump(@query_context[:params]))
|
|
31
|
+
|
|
32
|
+
next_params[:limit] = pagination.limit
|
|
33
|
+
next_params[:offset] = pagination.offset + pagination.limit
|
|
34
|
+
next_params.delete(:page)
|
|
35
|
+
next_params.delete(:size)
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
resource_class.find_by(next_params)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def respond_to_missing?(name, include_private = false)
|
|
41
|
+
name_str = Util.to_snake_case(name.to_s)
|
|
42
|
+
return true if name_str.end_with?('=')
|
|
43
|
+
return true if @attributes["data"]&.respond_to?(name_str)
|
|
44
|
+
|
|
45
|
+
@attributes.key?(name_str) || @attributes.key?(name_str.to_sym) || super
|
|
23
46
|
end
|
|
24
47
|
|
|
25
48
|
def method_missing(name, *args, &block)
|
|
@@ -30,14 +53,18 @@ module Conexa
|
|
|
30
53
|
end
|
|
31
54
|
|
|
32
55
|
unless block_given?
|
|
33
|
-
|
|
34
56
|
if name.end_with?('=') && args.size == 1
|
|
35
57
|
attribute_name = name[0...-1]
|
|
36
58
|
return self[attribute_name] = args[0]
|
|
37
59
|
end
|
|
38
60
|
|
|
39
61
|
if args.size == 0
|
|
40
|
-
|
|
62
|
+
if @attributes.key?(name)
|
|
63
|
+
return @attributes[name]
|
|
64
|
+
elsif @attributes.key?(name.to_sym)
|
|
65
|
+
return @attributes[name.to_sym]
|
|
66
|
+
end
|
|
67
|
+
return nil
|
|
41
68
|
end
|
|
42
69
|
end
|
|
43
70
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conexa
|
|
4
|
+
# RoomBooking resource (Reserva de Sala)
|
|
5
|
+
#
|
|
6
|
+
# @example Create a room booking
|
|
7
|
+
# booking = Conexa::RoomBooking.create(
|
|
8
|
+
# room_id: 5,
|
|
9
|
+
# customer_id: 127,
|
|
10
|
+
# start_date: '2026-04-01T10:00:00-03:00',
|
|
11
|
+
# end_date: '2026-04-01T12:00:00-03:00'
|
|
12
|
+
# )
|
|
13
|
+
#
|
|
14
|
+
# @example Find a room booking
|
|
15
|
+
# booking = Conexa::RoomBooking.find(143063)
|
|
16
|
+
#
|
|
17
|
+
# @example List room bookings
|
|
18
|
+
# bookings = Conexa::RoomBooking.all(limit: 50)
|
|
19
|
+
#
|
|
20
|
+
# @example Cancel a booking
|
|
21
|
+
# Conexa::RoomBooking.cancel(143063)
|
|
22
|
+
#
|
|
23
|
+
# @!attribute [r] booking_id
|
|
24
|
+
# @return [Integer] Booking ID (also accessible as #id)
|
|
25
|
+
# @!attribute [r] room_id
|
|
26
|
+
# @return [Integer] Room ID
|
|
27
|
+
# @!attribute [r] customer_id
|
|
28
|
+
# @return [Integer] Customer ID
|
|
29
|
+
# @!attribute [r] status
|
|
30
|
+
# @return [String] Booking status
|
|
31
|
+
#
|
|
32
|
+
class RoomBooking < Model
|
|
33
|
+
primary_key_attribute :booking_id
|
|
34
|
+
|
|
35
|
+
# Cancel this booking
|
|
36
|
+
# @return [self]
|
|
37
|
+
def cancel
|
|
38
|
+
Conexa::Request.patch(self.class.show_url(primary_key, "cancel")).call(class_name)
|
|
39
|
+
self
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Checkout this booking
|
|
43
|
+
# @return [self]
|
|
44
|
+
def checkout
|
|
45
|
+
Conexa::Request.post(self.class.show_url(primary_key, "checkout")).call(class_name)
|
|
46
|
+
self
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class << self
|
|
50
|
+
def url(*params)
|
|
51
|
+
["/room/bookings", *params].join '/'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def show_url(*params)
|
|
55
|
+
["/room/booking", *params].join '/'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Cancel a booking by ID
|
|
59
|
+
# @param id [Integer, String] booking ID
|
|
60
|
+
# @return [RoomBooking]
|
|
61
|
+
def cancel(id)
|
|
62
|
+
find(id).cancel
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Checkout a booking by ID
|
|
66
|
+
# @param id [Integer, String] booking ID
|
|
67
|
+
# @return [RoomBooking]
|
|
68
|
+
def checkout(id)
|
|
69
|
+
find(id).checkout
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Perform a checkin
|
|
73
|
+
# @param params [Hash] checkin parameters
|
|
74
|
+
# @return [ConexaObject]
|
|
75
|
+
def checkin(params = {})
|
|
76
|
+
Conexa::Request.post("/checkin", params: params).call("room_booking")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Perform a checkout (standalone)
|
|
80
|
+
# @param params [Hash] checkout parameters
|
|
81
|
+
# @return [ConexaObject]
|
|
82
|
+
def standalone_checkout(params = {})
|
|
83
|
+
Conexa::Request.post("/checkout", params: params).call("room_booking")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -12,7 +12,7 @@ module Conexa
|
|
|
12
12
|
# )
|
|
13
13
|
#
|
|
14
14
|
# @example List sales
|
|
15
|
-
# sales = Conexa::Sale.all(customer_id: [450], status: 'notBilled')
|
|
15
|
+
# sales = Conexa::Sale.all(customer_id: [450], status: 'notBilled', limit: 50)
|
|
16
16
|
#
|
|
17
17
|
# @!attribute [r] sale_id
|
|
18
18
|
# @return [Integer] Sale ID (also accessible as #id)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conexa
|
|
4
|
+
# ServiceCategory resource (Categoria de Serviço)
|
|
5
|
+
#
|
|
6
|
+
# @example Find a service category
|
|
7
|
+
# category = Conexa::ServiceCategory.find(1)
|
|
8
|
+
# category.name # => "Consultoria"
|
|
9
|
+
#
|
|
10
|
+
# @example List service categories
|
|
11
|
+
# categories = Conexa::ServiceCategory.all(limit: 50)
|
|
12
|
+
#
|
|
13
|
+
# @!attribute [r] service_category_id
|
|
14
|
+
# @return [Integer] Service category ID (also accessible as #id)
|
|
15
|
+
# @!attribute [r] name
|
|
16
|
+
# @return [String] Category name
|
|
17
|
+
# @!attribute [r] is_active
|
|
18
|
+
# @return [Boolean] Whether the category is active
|
|
19
|
+
#
|
|
20
|
+
class ServiceCategory < Model
|
|
21
|
+
primary_key_attribute :service_category_id
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
def url(*params)
|
|
25
|
+
["/serviceCategories", *params].join '/'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def show_url(*params)
|
|
29
|
+
["/serviceCategory", *params].join '/'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Conexa
|
|
4
|
+
# Supplier resource (Fornecedor)
|
|
5
|
+
#
|
|
6
|
+
# @example Create a supplier
|
|
7
|
+
# supplier = Conexa::Supplier.create(name: 'Fornecedor ABC')
|
|
8
|
+
#
|
|
9
|
+
# @example Find a supplier
|
|
10
|
+
# supplier = Conexa::Supplier.find(10)
|
|
11
|
+
# supplier.name # => "Fornecedor ABC"
|
|
12
|
+
#
|
|
13
|
+
# @example List suppliers
|
|
14
|
+
# suppliers = Conexa::Supplier.all(limit: 50)
|
|
15
|
+
#
|
|
16
|
+
# @!attribute [r] supplier_id
|
|
17
|
+
# @return [Integer] Supplier ID (also accessible as #id)
|
|
18
|
+
# @!attribute [r] name
|
|
19
|
+
# @return [String] Supplier name
|
|
20
|
+
# @!attribute [r] is_active
|
|
21
|
+
# @return [Boolean] Whether the supplier is active
|
|
22
|
+
#
|
|
2
23
|
class Supplier < Model
|
|
24
|
+
primary_key_attribute :supplier_id
|
|
25
|
+
|
|
3
26
|
class << self
|
|
4
27
|
def url(*params)
|
|
5
|
-
["/
|
|
28
|
+
["/suppliers", *params].join '/'
|
|
6
29
|
end
|
|
7
30
|
|
|
8
31
|
def show_url(*params)
|
data/lib/conexa/token_manager.rb
CHANGED
data/lib/conexa/util.rb
CHANGED
|
@@ -1,44 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Conexa
|
|
2
4
|
class Util
|
|
3
5
|
class << self
|
|
4
6
|
|
|
5
|
-
SINGULARS =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
7
|
+
SINGULARS = [
|
|
8
|
+
[/(ss)$/i, '\1'],
|
|
9
|
+
[/(n)ews$/i, '\1ews'],
|
|
10
|
+
[/([ti])a$/i, '\1um'],
|
|
11
|
+
[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '\1sis'],
|
|
12
|
+
[/(^analy)(sis|ses)$/i, '\1sis'],
|
|
13
|
+
[/([^f])ves$/i, '\1fe'],
|
|
14
|
+
[/(hive)s$/i, '\1'],
|
|
15
|
+
[/(tive)s$/i, '\1'],
|
|
16
|
+
[/([lr])ves$/i, '\1f'],
|
|
17
|
+
[/([^aeiouy]|qu)ies$/i, '\1y'],
|
|
18
|
+
[/(s)eries$/i, '\1eries'],
|
|
19
|
+
[/(m)ovies$/i, '\1ovie'],
|
|
20
|
+
[/(x|ch|ss|sh)es$/i, '\1'],
|
|
21
|
+
[/^(m|l)ice$/i, '\1ouse'],
|
|
22
|
+
[/(bus)(es)?$/i, '\1'],
|
|
23
|
+
[/(o)es$/i, '\1'],
|
|
24
|
+
[/(shoe)s$/i, '\1'],
|
|
25
|
+
[/(cris|test)(is|es)$/i, '\1is'],
|
|
26
|
+
[/^(a)x[ie]s$/i, '\1xis'],
|
|
27
|
+
[/(octop|vir)(us|i)$/i, '\1us'],
|
|
28
|
+
[/(alias|status)(es)?$/i, '\1'],
|
|
29
|
+
[/^(ox)en/i, '\1'],
|
|
30
|
+
[/(vert|ind)ices$/i, '\1ex'],
|
|
31
|
+
[/(matr)ices$/i, '\1ix'],
|
|
32
|
+
[/(quiz)zes$/i, '\1'],
|
|
33
|
+
[/(database)s$/i, '\1'],
|
|
34
|
+
[/s$/i, '']
|
|
35
|
+
].freeze
|
|
33
36
|
|
|
34
|
-
def singularize
|
|
35
|
-
|
|
36
|
-
SINGULARS.
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
def singularize(resource)
|
|
38
|
+
str = resource.to_s
|
|
39
|
+
SINGULARS.each do |pattern, replacement|
|
|
40
|
+
result = str.sub(pattern, replacement)
|
|
41
|
+
return resource.is_a?(Symbol) ? result.to_sym : result if result != str
|
|
39
42
|
end
|
|
40
|
-
|
|
41
|
-
resource.is_a?(Symbol) ? out.to_sym : out
|
|
43
|
+
resource
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def to_sym string
|
|
@@ -77,18 +79,3 @@ module Conexa
|
|
|
77
79
|
end
|
|
78
80
|
end
|
|
79
81
|
end
|
|
80
|
-
|
|
81
|
-
class Hash
|
|
82
|
-
def except_nested(key)
|
|
83
|
-
r = Marshal.load(Marshal.dump(self))
|
|
84
|
-
r.except_nested!(key)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def except_nested!(key)
|
|
88
|
-
self.reject!{|k, _| k == key || k.to_s == key }
|
|
89
|
-
self.each do |_, v|
|
|
90
|
-
v.except_nested!(key) if v.is_a?(Hash)
|
|
91
|
-
v.map!{|obj| obj.except_nested!(key) if obj.is_a?(Hash)} if v.is_a?(Array)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
data/lib/conexa/version.rb
CHANGED
data/lib/conexa.rb
CHANGED
|
@@ -9,7 +9,7 @@ require_relative "conexa/core_ext"
|
|
|
9
9
|
require_relative "conexa/errors"
|
|
10
10
|
require_relative "conexa/util"
|
|
11
11
|
require_relative "conexa/configuration"
|
|
12
|
-
require_relative "conexa/
|
|
12
|
+
require_relative "conexa/order_common"
|
|
13
13
|
require_relative "conexa/token_manager"
|
|
14
14
|
|
|
15
15
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: conexa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Guilherme Gazzinelli
|
|
@@ -153,25 +153,33 @@ files:
|
|
|
153
153
|
- lib/conexa/generators/install_generator.rb
|
|
154
154
|
- lib/conexa/model.rb
|
|
155
155
|
- lib/conexa/object.rb
|
|
156
|
-
- lib/conexa/
|
|
156
|
+
- lib/conexa/order_common.rb
|
|
157
157
|
- lib/conexa/request.rb
|
|
158
|
+
- lib/conexa/resources/account.rb
|
|
158
159
|
- lib/conexa/resources/address.rb
|
|
159
160
|
- lib/conexa/resources/auth.rb
|
|
160
161
|
- lib/conexa/resources/bill.rb
|
|
162
|
+
- lib/conexa/resources/bill_category.rb
|
|
163
|
+
- lib/conexa/resources/bill_subcategory.rb
|
|
161
164
|
- lib/conexa/resources/charge.rb
|
|
162
165
|
- lib/conexa/resources/company.rb
|
|
163
166
|
- lib/conexa/resources/contract.rb
|
|
167
|
+
- lib/conexa/resources/cost_center.rb
|
|
164
168
|
- lib/conexa/resources/credit_card.rb
|
|
165
169
|
- lib/conexa/resources/customer.rb
|
|
166
170
|
- lib/conexa/resources/invoicing_method.rb
|
|
167
171
|
- lib/conexa/resources/legal_person.rb
|
|
168
172
|
- lib/conexa/resources/pagination.rb
|
|
173
|
+
- lib/conexa/resources/payment_method.rb
|
|
169
174
|
- lib/conexa/resources/person.rb
|
|
170
175
|
- lib/conexa/resources/plan.rb
|
|
171
176
|
- lib/conexa/resources/product.rb
|
|
177
|
+
- lib/conexa/resources/receiving_method.rb
|
|
172
178
|
- lib/conexa/resources/recurring_sale.rb
|
|
173
179
|
- lib/conexa/resources/result.rb
|
|
180
|
+
- lib/conexa/resources/room_booking.rb
|
|
174
181
|
- lib/conexa/resources/sale.rb
|
|
182
|
+
- lib/conexa/resources/service_category.rb
|
|
175
183
|
- lib/conexa/resources/supplier.rb
|
|
176
184
|
- lib/conexa/token_manager.rb
|
|
177
185
|
- lib/conexa/util.rb
|