monokera-sdk 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +35 -0
- data/.github/dependabot.yml +44 -0
- data/.github/pull_request_template.md +15 -0
- data/.github/workflows/ci.yml +67 -0
- data/.github/workflows/lint.yml +28 -0
- data/.gitignore +18 -0
- data/.markdownlint.yaml +6 -0
- data/.rspec +1 -0
- data/.rubocop.yml +15 -0
- data/.yamllint.yml +6 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +166 -0
- data/CODEOWNERS +8 -0
- data/Gemfile +6 -0
- data/Guardfile +19 -0
- data/README.md +37 -0
- data/Rakefile +8 -0
- data/bin/bump +20 -0
- data/bin/console +12 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/build_tools/changelog.rb +52 -0
- data/build_tools/spec/changelog_spec.rb +36 -0
- data/build_tools/spec/fixtures/CHANGELOG.md +11 -0
- data/docs/product_definition.md +48 -0
- data/lib/monokera/sdk.rb +18 -0
- data/lib/monokera/sdk/active_client.rb +44 -0
- data/lib/monokera/sdk/active_model.rb +150 -0
- data/lib/monokera/sdk/active_model_serializer.rb +11 -0
- data/lib/monokera/sdk/active_support_notifications.rb +27 -0
- data/lib/monokera/sdk/billing_service/client.rb +9 -0
- data/lib/monokera/sdk/billing_service/configuration.rb +13 -0
- data/lib/monokera/sdk/billing_service/models/installment_item.rb +17 -0
- data/lib/monokera/sdk/billing_service/models/plan_installment.rb +17 -0
- data/lib/monokera/sdk/cancellation_request.rb +18 -0
- data/lib/monokera/sdk/claim.rb +24 -0
- data/lib/monokera/sdk/claim_service/client.rb +9 -0
- data/lib/monokera/sdk/claim_service/configuration.rb +13 -0
- data/lib/monokera/sdk/claim_service/models/attendant.rb +14 -0
- data/lib/monokera/sdk/claim_service/models/setting.rb +17 -0
- data/lib/monokera/sdk/client_base.rb +113 -0
- data/lib/monokera/sdk/client_deprecation.rb +37 -0
- data/lib/monokera/sdk/client_service/client.rb +9 -0
- data/lib/monokera/sdk/client_service/configuration.rb +13 -0
- data/lib/monokera/sdk/config/gem_inflector.rb +17 -0
- data/lib/monokera/sdk/configuration.rb +57 -0
- data/lib/monokera/sdk/configurator.rb +15 -0
- data/lib/monokera/sdk/consolidated_pricing.rb +9 -0
- data/lib/monokera/sdk/coverage.rb +18 -0
- data/lib/monokera/sdk/credential.rb +18 -0
- data/lib/monokera/sdk/customer.rb +26 -0
- data/lib/monokera/sdk/customer_prospect.rb +24 -0
- data/lib/monokera/sdk/customer_service/client.rb +9 -0
- data/lib/monokera/sdk/customer_service/configuration.rb +13 -0
- data/lib/monokera/sdk/customer_service/models/address.rb +15 -0
- data/lib/monokera/sdk/document.rb +19 -0
- data/lib/monokera/sdk/document_service/client.rb +9 -0
- data/lib/monokera/sdk/document_service/configuration.rb +13 -0
- data/lib/monokera/sdk/endorsed_plan_preview.rb +9 -0
- data/lib/monokera/sdk/endorsement.rb +26 -0
- data/lib/monokera/sdk/error.rb +61 -0
- data/lib/monokera/sdk/good.rb +17 -0
- data/lib/monokera/sdk/hash_model.rb +29 -0
- data/lib/monokera/sdk/middleware/custom_logger_middleware.rb +89 -0
- data/lib/monokera/sdk/middleware/service_middleware.rb +25 -0
- data/lib/monokera/sdk/model.rb +49 -0
- data/lib/monokera/sdk/model/error.rb +14 -0
- data/lib/monokera/sdk/model/error_message.rb +14 -0
- data/lib/monokera/sdk/plan.rb +22 -0
- data/lib/monokera/sdk/policy.rb +32 -0
- data/lib/monokera/sdk/policy_service/client.rb +9 -0
- data/lib/monokera/sdk/policy_service/configuration.rb +13 -0
- data/lib/monokera/sdk/policy_service/models/address.rb +21 -0
- data/lib/monokera/sdk/policy_service/models/document.rb +15 -0
- data/lib/monokera/sdk/policy_service/models/endorsement_operation.rb +15 -0
- data/lib/monokera/sdk/policy_service/models/policy_holder.rb +22 -0
- data/lib/monokera/sdk/policy_service/models/pricing_history.rb +15 -0
- data/lib/monokera/sdk/policy_service/models/setting.rb +15 -0
- data/lib/monokera/sdk/pricing.rb +20 -0
- data/lib/monokera/sdk/pricing_service/client.rb +9 -0
- data/lib/monokera/sdk/pricing_service/configuration.rb +13 -0
- data/lib/monokera/sdk/pricing_service/models/setting.rb +15 -0
- data/lib/monokera/sdk/pricing_snapshot.rb +9 -0
- data/lib/monokera/sdk/product.rb +21 -0
- data/lib/monokera/sdk/product_definition/client.rb +9 -0
- data/lib/monokera/sdk/product_definition/configuration.rb +13 -0
- data/lib/monokera/sdk/product_definition/models/condition.rb +15 -0
- data/lib/monokera/sdk/product_definition/models/deductible.rb +14 -0
- data/lib/monokera/sdk/product_definition/models/limit.rb +16 -0
- data/lib/monokera/sdk/product_definition/models/rate.rb +15 -0
- data/lib/monokera/sdk/product_definition/models/setting.rb +20 -0
- data/lib/monokera/sdk/quote.rb +29 -0
- data/lib/monokera/sdk/quote_service/client.rb +9 -0
- data/lib/monokera/sdk/quote_service/configuration.rb +13 -0
- data/lib/monokera/sdk/quote_service/models/address.rb +21 -0
- data/lib/monokera/sdk/quote_service/models/customer_prospect.rb +23 -0
- data/lib/monokera/sdk/quote_service/models/setting.rb +15 -0
- data/lib/monokera/sdk/resource_not_found.rb +7 -0
- data/lib/monokera/sdk/validity.rb +18 -0
- data/lib/monokera/sdk/version.rb +7 -0
- data/monokera-sdk.gemspec +45 -0
- metadata +423 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module Middleware
|
6
|
+
class ServiceMiddleware < Faraday::Middleware
|
7
|
+
def initialize(app, options = {})
|
8
|
+
super(app)
|
9
|
+
@service_name = options.fetch(:service_name, 'unknown-service')
|
10
|
+
@origin_service_name = ENV['APP_NAME']
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
ActiveSupport::Notifications.instrument('monokera-sdk.request.faraday', env) do
|
15
|
+
env[:service_name] ||= @service_name
|
16
|
+
env[:origin_service_name] ||= @origin_service_name
|
17
|
+
@app.call(env)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Faraday::Response.register_middleware(custom_service: Monokera::SDK::Middleware::ServiceMiddleware)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'virtus'
|
4
|
+
require 'active_support/json'
|
5
|
+
require 'active_support/core_ext'
|
6
|
+
|
7
|
+
module Monokera
|
8
|
+
module SDK
|
9
|
+
class Model
|
10
|
+
include Virtus.model
|
11
|
+
include Monokera::SDK::ActiveModelSerializer
|
12
|
+
|
13
|
+
attribute :errors, Set[Error], default: []
|
14
|
+
|
15
|
+
def add_error(attribute, code, description)
|
16
|
+
error = errors.find(-> { Error.new(attribute: attribute) }) { |e| e.attribute == attribute.to_s }
|
17
|
+
error.messages << ErrorMessage.new(code: code, description: description)
|
18
|
+
|
19
|
+
errors.add(error)
|
20
|
+
end
|
21
|
+
|
22
|
+
def valid?
|
23
|
+
errors.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def as_json(*)
|
27
|
+
json = super
|
28
|
+
except_attributes!(json, 'errors')
|
29
|
+
json.with_indifferent_access
|
30
|
+
end
|
31
|
+
|
32
|
+
def except_attributes!(model, *attributes_to_reject)
|
33
|
+
if model.is_a?(Hash)
|
34
|
+
model.except!(*attributes_to_reject).each_value do |child|
|
35
|
+
except_attributes!(child, *attributes_to_reject)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_json(_options = nil)
|
41
|
+
JSON.generate(as_json)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.model_name
|
45
|
+
self.name.to_s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
class Plan < Monokera::SDK::ActiveModel
|
6
|
+
attribute :billable_id
|
7
|
+
attribute :billable_product
|
8
|
+
attribute :total_amount
|
9
|
+
attribute :initial_date
|
10
|
+
attribute :installments_count
|
11
|
+
attribute :installments_frequency
|
12
|
+
attribute :status
|
13
|
+
attribute :installments, Array[BillingService::Models::PlanInstallment]
|
14
|
+
|
15
|
+
BASE_ENDPOINT = '/v1/plans'
|
16
|
+
|
17
|
+
def self.client
|
18
|
+
@client ||= BillingService::Client.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
class Policy < Monokera::SDK::ActiveModel
|
6
|
+
attribute :product
|
7
|
+
attribute :number
|
8
|
+
attribute :quote_id
|
9
|
+
attribute :pricing_id
|
10
|
+
attribute :status
|
11
|
+
attribute :issued_at
|
12
|
+
attribute :cancelled_at
|
13
|
+
attribute :effective_from
|
14
|
+
attribute :effective_until
|
15
|
+
attribute :customer_id
|
16
|
+
attribute :product_uid
|
17
|
+
attribute :product_version
|
18
|
+
|
19
|
+
attribute :cancellation, CancellationRequest
|
20
|
+
attribute :pricing_history, Array[PolicyService::Models::PricingHistory]
|
21
|
+
attribute :holder, PolicyService::Models::PolicyHolder
|
22
|
+
attribute :documents, Array[PolicyService::Models::Document]
|
23
|
+
attribute :settings, Array[PolicyService::Models::Setting]
|
24
|
+
|
25
|
+
BASE_ENDPOINT = '/v1/policies'
|
26
|
+
|
27
|
+
def self.client
|
28
|
+
@client ||= PolicyService::Client.new
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module PolicyService
|
6
|
+
module Models
|
7
|
+
class Address < Monokera::SDK::Model
|
8
|
+
attribute :street, String
|
9
|
+
attribute :complement, String
|
10
|
+
attribute :neighborhood, String
|
11
|
+
attribute :city, String
|
12
|
+
attribute :state, String
|
13
|
+
attribute :country, String
|
14
|
+
attribute :zip_code, String
|
15
|
+
attribute :latitude, String
|
16
|
+
attribute :longitude, String
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module PolicyService
|
6
|
+
module Models
|
7
|
+
class Document < Monokera::SDK::Model
|
8
|
+
attribute :integration_id, String
|
9
|
+
attribute :document_type, String
|
10
|
+
attribute :reference_number, String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module PolicyService
|
6
|
+
module Models
|
7
|
+
class EndorsementOperation < Monokera::SDK::Model
|
8
|
+
attribute :code, String
|
9
|
+
attribute :pricing_id, String
|
10
|
+
attribute :needs_repricing, Boolean
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module PolicyService
|
6
|
+
module Models
|
7
|
+
class PolicyHolder < Monokera::SDK::Model
|
8
|
+
attribute :name, String
|
9
|
+
attribute :first_name, String
|
10
|
+
attribute :middle_name, String
|
11
|
+
attribute :last_name, String
|
12
|
+
attribute :second_last_name, String
|
13
|
+
attribute :document_number, String
|
14
|
+
attribute :document_type, String
|
15
|
+
attribute :phone, String
|
16
|
+
attribute :email, String
|
17
|
+
attribute :address, PolicyService::Models::Address
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module PolicyService
|
6
|
+
module Models
|
7
|
+
class PricingHistory < Monokera::SDK::Model
|
8
|
+
attribute :pricing_id, String
|
9
|
+
attribute :effective_from, String
|
10
|
+
attribute :effective_until, String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module PolicyService
|
6
|
+
module Models
|
7
|
+
class Setting < Monokera::SDK::Model
|
8
|
+
attribute :coverage_uid
|
9
|
+
attribute :good_uid
|
10
|
+
attribute :insured_value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
class Pricing < Monokera::SDK::ActiveModel
|
6
|
+
attribute :id
|
7
|
+
attribute :original_id
|
8
|
+
attribute :premium
|
9
|
+
attribute :insured_value
|
10
|
+
|
11
|
+
attribute :settings, Array[PricingService::Models::Setting]
|
12
|
+
|
13
|
+
BASE_ENDPOINT = '/v1/pricings'
|
14
|
+
|
15
|
+
def self.client
|
16
|
+
@client ||= PricingService::Client.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module PricingService
|
6
|
+
module Models
|
7
|
+
class Setting < Monokera::SDK::Model
|
8
|
+
attribute :coverage_uid, String
|
9
|
+
attribute :good_uid, String
|
10
|
+
attribute :premium, String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
class Product < Monokera::SDK::ActiveModel
|
6
|
+
attribute :uid, String
|
7
|
+
attribute :name, String
|
8
|
+
attribute :description, String
|
9
|
+
attribute :version
|
10
|
+
attribute :quote_validity
|
11
|
+
attribute :quote_validity_type
|
12
|
+
attribute :settings, Array[ProductDefinition::Models::Setting]
|
13
|
+
|
14
|
+
BASE_ENDPOINT = '/v1/products'
|
15
|
+
|
16
|
+
def self.client
|
17
|
+
@client ||= ProductDefinition::Client.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monokera
|
4
|
+
module SDK
|
5
|
+
module ProductDefinition
|
6
|
+
module Models
|
7
|
+
class Condition < Monokera::SDK::Model
|
8
|
+
attribute :name, String
|
9
|
+
attribute :description, String
|
10
|
+
attribute :type, String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|