Sha256: c236ea4847d0f9c6f68ef67538fd7db084540aaff4bbc7e0d52952d21e15feba
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
module LedgerSync module Adaptors module Test module Account module Operations class Create < Operation::Create class Contract < LedgerSync::Adaptors::Contract schema do required(:external_id).maybe(:string) required(:ledger_id).value(:nil) required(:name).filled(:string) required(:classification).filled(:string) required(:account_type).filled(:string) required(:account_sub_type).filled(:string) required(:number).maybe(:integer) required(:currency).maybe(:hash, Types::Reference) required(:description).maybe(:string) required(:active).maybe(:bool) end end private def id SecureRandom.uuid end def local_resource_data { 'name' => resource.name, 'classification' => resource.classification, 'account_type' => resource.account_type, 'account_sub_type' => resource.account_sub_type } end def operate response = adaptor.post( resource: 'account', payload: local_resource_data.merge( 'id' => id ) ) resource.ledger_id = response.dig('id') success( resource: Test::LedgerSerializer.new(resource: resource).deserialize(hash: response), response: response ) end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ledger_sync-1.3.2 | lib/ledger_sync/adaptors/test/account/operations/create.rb |