Class: Inferno::DSL::FHIRClientBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/dsl/fhir_client_builder.rb

Overview

DSL for configuring FHIR clients

Examples:

input :url
input :fhir_credentials, type: :oauth_credentials
input :access_token

fhir_client do
  url :url
  headers 'My-Custom_header' => 'CUSTOM_HEADER_VALUE'
  oauth_credentials :fhir_credentials
end

fhir_client :with_bearer_token do
  url :url
  bearer_token :access_token
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



92
93
94
95
96
# File 'lib/inferno/dsl/fhir_client_builder.rb', line 92

def method_missing(name, *args, &)
  return runnable.send(name, *args, &) if runnable.respond_to? name

  super
end

Instance Attribute Details

#runnableObject

Returns the value of attribute runnable.



24
25
26
# File 'lib/inferno/dsl/fhir_client_builder.rb', line 24

def runnable
  @runnable
end

Instance Method Details

#bearer_token(bearer_token = nil) ⇒ void

This method returns an undefined value.

Define the bearer token for a client. A string or symbol can be provided. A string is interpreted as a token. A symbol is interpreted as the name of an input to the Runnable.

Parameters:

  • bearer_token (String, Symbol) (defaults to: nil)


60
61
62
63
64
65
66
67
# File 'lib/inferno/dsl/fhir_client_builder.rb', line 60

def bearer_token(bearer_token = nil)
  @bearer_token ||=
    if bearer_token.is_a? Symbol
      runnable.send(bearer_token)
    else
      bearer_token
    end
end

#headers(headers = nil) ⇒ void

This method returns an undefined value.

Define custom headers for a client

Parameters:

  • headers (Hash) (defaults to: nil)


87
88
89
# File 'lib/inferno/dsl/fhir_client_builder.rb', line 87

def headers(headers = nil)
  @headers ||= headers
end

#oauth_credentials(oauth_credentials = nil) ⇒ void

This method returns an undefined value.

Define OAuth credentials for a client. These can allow a client to automatically refresh its access token when it expires.

Parameters:



74
75
76
77
78
79
80
81
# File 'lib/inferno/dsl/fhir_client_builder.rb', line 74

def oauth_credentials(oauth_credentials = nil)
  @oauth_credentials ||=
    if oauth_credentials.is_a? Symbol
      runnable.send(oauth_credentials)
    else
      oauth_credentials
    end
end

#url(url = nil) ⇒ void

This method returns an undefined value.

Define the base FHIR url for a client. A string or symbol can be provided. A string is interpreted as a url. A symbol is interpreted as the name of an input to the Runnable.

Parameters:

  • url (String, Symbol) (defaults to: nil)


45
46
47
48
49
50
51
52
# File 'lib/inferno/dsl/fhir_client_builder.rb', line 45

def url(url = nil)
  @url ||=
    if url.is_a? Symbol
      runnable.send(url)
    else
      url
    end&.chomp('/')
end