Class: Sbuilder::Interfaces::Salesforce::SalesforceLoader
- Inherits:
-
ApiLoaderPlugin
- Object
- ApiLoaderPlugin
- Sbuilder::Interfaces::Salesforce::SalesforceLoader
- Defined in:
- lib/sbuilder/sales_force_loader.rb
Instance Attribute Summary collapse
-
#reader ⇒ Object
readonly
[Sbuilder::Interfaces::Salesforce::Reader].
Class Method Summary collapse
Instance Method Summary collapse
-
#doLoadDefinitions(config_hash) ⇒ Object
Iterate ‘definitions’: for each definition create ‘newDefinition’, for each field ‘newParameter’, add new definition to ‘facadade’.
-
#doLoadInterfaces(operationDefs) ⇒ Object
Iterate ‘path’: for each path create ‘newInterface’.
-
#initialize(options = {}) ⇒ SalesforceLoader
constructor
—————————————————————— constructore.
- #load(yamlFileUri) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SalesforceLoader
constructore
18 19 20 21 |
# File 'lib/sbuilder/sales_force_loader.rb', line 18 def initialize( ={} ) super @reader = Sbuilder::Interfaces::Salesforce::Reader.new( ) end |
Instance Attribute Details
#reader ⇒ Object (readonly)
- Sbuilder::Interfaces::Salesforce::Reader
13 14 15 |
# File 'lib/sbuilder/sales_force_loader.rb', line 13 def reader @reader end |
Class Method Details
.configure(configuration) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sbuilder/sales_force_loader.rb', line 28 def self.configure( configuration ) configuration.each do |k,v| begin Config.configuration.method( "#{k}=".to_sym ).call( v ) rescue NameError => e msg = <<-EOS #{e.} in salesforce loader configuration #{configuration.to_yaml} EOS raise NameError, msg, e.backtrace end end end |
Instance Method Details
#doLoadDefinitions(config_hash) ⇒ Object
Iterate ‘definitions’: for each definition create ‘newDefinition’, for each field ‘newParameter’, add new definition to ‘facadade’
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/sbuilder/sales_force_loader.rb', line 84 def doLoadDefinitions( config_hash ) # load unique 'sObjects' in operation defs definitions = config_hash.map { |operationDef| operationDef['sObject']}.uniq definitions.each do |definition| paramSet = facade.newDefinition( definition ) isArray = false fields = fields( definition ).each do |field| parameter = facade.newParameter( field[:name], isArray ) paramSet.addParameter( parameter ) end facade.modelDefinition( paramSet ) end end |
#doLoadInterfaces(operationDefs) ⇒ Object
Iterate ‘path’: for each path create ‘newInterface’
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/sbuilder/sales_force_loader.rb', line 101 def doLoadInterfaces( operationDefs ) operationDefs.each do |operationDef| logger.debug "#{__method__}, operationDef=#{operationDef}" validateProperties( operationDef, ['action', 'sObject', 'request', 'reply', 'path' ] , [] ) # read salesforce [Hash:Array] of :path valid_urls = read_urls( operationDef['sObject'] ) request = facade.newInterface( operationDef['path'], operationDef['action'] ) # access parameter set for response from request response = request.response input = facade.newParameterReference( 'request', operationDef['request'], false ) request.addParameter( input ) # configure reponse to return # [ # operationDef['reply'] |-> operationDef['sObject'], # status |-> status] # ] logger.info "#{__method__}, reponse#{operationDef['sObject']}, status="#{operationDef['reply']}" response.addParameter( facade.newParameterReference( 'reply', operationDef['reply'], false ) ) if operationDef['reply'] # add fully configured pojo to model facade.modelInterface( request ) end end |
#load(yamlFileUri) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sbuilder/sales_force_loader.rb', line 49 def load( yamlFileUri ) logger.info( "#{__method__} yamlFileUri=#{yamlFileUri}" ) # access plugin confiration config_hash = readConfig( yamlFileUri ) # and extract interfaces && definitions doLoadDefinitions( config_hash ) doLoadInterfaces( config_hash ) end |