Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Restforce
- attr_reader :client
- def initialize
- @client = initialize_client
- @client.authenticate!
- end
- def initialize_client
- config = Rails.application.secrets.salesforce
- Restforce.new(
- security_token: config["security_token"],
- client_secret: config["client_secret"],
- client_id: config["client_id"],
- api_version: config["api_version"]
- username: config["username"],
- password: config["password"],
- host: config["host"]
- )
- end
- def obtain_account(model, id_externo)
- client.find(model, id_externo)
- end
- def destroy_account(model, id_externo)
- client.destroy(model, id_externo)
- end
- def obtain_description_from_account(id_externo)
- client.query("select Description from Account where External__c = '#{id_externo}'").first
- end
- def create_or_update_account(account)
- client.upsert!('Account', 'External__c',
- Name: account.id.to_s,
- External__c: account.id.to_s,
- Description: account.description
- )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement