Class: JxClient

Inherits:
Object
  • Object
show all
Defined in:
lib/jx_client.rb,
lib/jx_client/version.rb,
lib/jx_client/get_document.rb,
lib/jx_client/put_document.rb,
lib/jx_client/operation_base.rb,
lib/jx_client/confirm_document.rb,
lib/jx_client/get_document_result.rb

Overview

JX手順クライアント

Defined Under Namespace

Classes: ConfirmDocument, Error, GetDocument, GetDocumentResult, OperationBase, PutDocument

Constant Summary collapse

DEFAULT_OPTIONS =
{
  env_namespace: :soap,
  convert_request_keys_to: :none,
}.freeze
VERSION =
"0.1.1"
GET_DOCUMENT_PROPERTIES =
[
  :get_document_result,
  :message_id,
  :data,
  :sender_id,
  :receiver_id,
  :format_type,
  :document_type,
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|client| ... } ⇒ JxClient

Returns a new instance of JxClient.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :jx_version (2004 | 2007)

    JX手順のバージョン

  • :jx_message_id_generate (Proc | Boolean)

    メッセージID生成 (true: デフォルト, false: 無効, Proc: カスタム生成)

  • :jx_timestamp_generate (Proc | Boolean)

    timestamp生成 (true: デフォルト, false: 無効, Proc: カスタム生成)

  • :jx_default_options (Hash)

    デフォルトオプション

  • :jx_default_put_document_options (Hash)

    PutDocumentのデフォルトオプション

  • :jx_default_get_document_options (Hash)

    GetDocumentのデフォルトオプション

  • :jx_default_confirm_document_options (Hash)

    ConfirmDocumentのデフォルトオプション

Yields:

  • (client)

    Savon.client(&block)



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/jx_client.rb', line 51

def initialize(options = {}, &block)
  @savon_client_options = DEFAULT_OPTIONS.merge(options)
  @jx_version = @savon_client_options.delete(:jx_version) || 2007
  @jx_message_id_generate = @savon_client_options.delete(:jx_message_id_generate)
  @jx_timestamp_generate = @savon_client_options.delete(:jx_timestamp_generate)
  @jx_default_options = @savon_client_options.delete(:jx_default_options) || {}
  @jx_default_put_document_options = @savon_client_options.delete(:jx_default_put_document_options) || {}
  @jx_default_get_document_options = @savon_client_options.delete(:jx_default_get_document_options) || {}
  @jx_default_confirm_document_options = @savon_client_options.delete(:jx_default_confirm_document_options) || {}
  @savon_client_block = block
end

Instance Attribute Details

#jx_default_confirm_document_optionsObject (readonly)

Returns the value of attribute jx_default_confirm_document_options.



34
35
36
# File 'lib/jx_client.rb', line 34

def jx_default_confirm_document_options
  @jx_default_confirm_document_options
end

#jx_default_get_document_optionsObject (readonly)

Returns the value of attribute jx_default_get_document_options.



34
35
36
# File 'lib/jx_client.rb', line 34

def jx_default_get_document_options
  @jx_default_get_document_options
end

#jx_default_optionsObject (readonly)

Returns the value of attribute jx_default_options.



34
35
36
# File 'lib/jx_client.rb', line 34

def jx_default_options
  @jx_default_options
end

#jx_default_put_document_optionsObject (readonly)

Returns the value of attribute jx_default_put_document_options.



34
35
36
# File 'lib/jx_client.rb', line 34

def jx_default_put_document_options
  @jx_default_put_document_options
end

#jx_message_id_generateObject (readonly)

Returns the value of attribute jx_message_id_generate.



34
35
36
# File 'lib/jx_client.rb', line 34

def jx_message_id_generate
  @jx_message_id_generate
end

#jx_timestamp_generateObject (readonly)

Returns the value of attribute jx_timestamp_generate.



34
35
36
# File 'lib/jx_client.rb', line 34

def jx_timestamp_generate
  @jx_timestamp_generate
end

#jx_versionObject (readonly)

Returns the value of attribute jx_version.



34
35
36
# File 'lib/jx_client.rb', line 34

def jx_version
  @jx_version
end

Class Method Details

.wsdl(version:) ⇒ Object

WSDL content

Parameters:

  • version (2004 | 2007)


22
23
24
25
# File 'lib/jx_client.rb', line 22

def wsdl(version:)
  @wsdl ||= {}
  @wsdl[version] ||= File.read(wsdl_path(version: version))
end

.wsdl_path(version:) ⇒ Object

WSDL file path

Parameters:

  • version (2004 | 2007)


29
30
31
# File 'lib/jx_client.rb', line 29

def wsdl_path(version:)
  File.expand_path("../../wsdl/jx#{version}.wsdl.xml", __FILE__)
end

Instance Method Details

#clientSavon::Client

Returns:

  • (Savon::Client)


64
65
66
# File 'lib/jx_client.rb', line 64

def client
  @client ||= Savon.client(client_options, &@savon_client_block)
end

#client_optionsHash

Returns Savon.clientのオプション.

Returns:

  • (Hash)

    Savon.clientのオプション



69
70
71
72
73
74
75
# File 'lib/jx_client.rb', line 69

def client_options
  if @jx_version
    @savon_client_options.merge(wsdl: wsdl)
  else
    @savon_client_options
  end
end

#confirm_document {|operation| ... } ⇒ JxClient::ConfirmDocument

Yields:

  • (operation)

Yield Parameters:

Returns:



104
105
106
107
108
# File 'lib/jx_client.rb', line 104

def confirm_document
  ConfirmDocument.from_jx_client(self).tap do |operation|
    yield operation if block_given?
  end
end

#get_document {|operation| ... } ⇒ JxClient::GetDocument

Yields:

  • (operation)

Yield Parameters:

Returns:



95
96
97
98
99
# File 'lib/jx_client.rb', line 95

def get_document # rubocop:disable Naming/AccessorMethodName
  GetDocument.from_jx_client(self).tap do |operation|
    yield operation if block_given?
  end
end

#put_document {|operation| ... } ⇒ JxClient::PutDocument

Yields:

  • (operation)

Yield Parameters:

Returns:



86
87
88
89
90
# File 'lib/jx_client.rb', line 86

def put_document
  PutDocument.from_jx_client(self).tap do |operation|
    yield operation if block_given?
  end
end

#wsdlString

WSDL content

Returns:

  • (String)


79
80
81
# File 'lib/jx_client.rb', line 79

def wsdl
  @wsdl ||= JxClient.wsdl(version: @jx_version)
end