Class: Bulkforce::ConnectionBuilder
- Inherits:
-
Object
- Object
- Bulkforce::ConnectionBuilder
- Defined in:
- lib/bulkforce/connection_builder.rb
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(host:, api_version:, **credentials) ⇒ ConnectionBuilder
constructor
A new instance of ConnectionBuilder.
Constructor Details
#initialize(host:, api_version:, **credentials) ⇒ ConnectionBuilder
Returns a new instance of ConnectionBuilder.
7 8 9 10 11 |
# File 'lib/bulkforce/connection_builder.rb', line 7 def initialize(host:, api_version:, **credentials) @host = host @api_version = api_version @credentials = credentials end |
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
4 5 6 |
# File 'lib/bulkforce/connection_builder.rb', line 4 def api_version @api_version end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
5 6 7 |
# File 'lib/bulkforce/connection_builder.rb', line 5 def credentials @credentials end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/bulkforce/connection_builder.rb', line 3 def host @host end |
Instance Method Details
#build ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bulkforce/connection_builder.rb', line 13 def build = { api_version: api_version } = if credentials[:session_id] { session_id: credentials[:session_id], instance: credentials.fetch(:instance), } elsif credentials[:refresh_token] Bulkforce::Http.oauth_login( host, credentials.fetch(:client_id), credentials.fetch(:client_secret), credentials[:refresh_token] ) else Bulkforce::Http.login( host, credentials.fetch(:username), "#{credentials.fetch(:password)}#{credentials.fetch(:security_token)}", api_version ) end.select { |k, _| [:session_id, :instance].include?(k) }.to_h Bulkforce::Connection.new(.merge()) end |