Sha256: edf11db4ff4166bc6fa736e8cbad6c815299bffdf141f95dac52a03bee28c799
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 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(:string) 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
3 entries across 3 versions & 1 rubygems