salesforceintegration 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5687d322f96a2cd170f6c120484de8dbc34aa74a
4
- data.tar.gz: fe99d8042a82d80fde89707deaaae7f30dc4f1ae
3
+ metadata.gz: 05f9e22481d1a246d307536606107a7b4cd45e34
4
+ data.tar.gz: eb68af81d3eef33ba77eef599679ca3ae3e55930
5
5
  SHA512:
6
- metadata.gz: 2a8244aa943dba73a0527789522b02421cf4f1b59f9b7037b65bb3bbf560c8a274a7a267adcc5f9837a377ac3c637ad8fb742b1b786c19767bbcc1f99c8c6e33
7
- data.tar.gz: 0d4a96aef7537bb69fad98153c87e38c044715722c0555e6b0b9953f91f1f1acd381ece5dbdbbb2cd4982d57756c8da2235820e5ec7c85d04f3998a219fd9cc4
6
+ metadata.gz: ffdf565994e6fd20be4c65f12d4f37412bf9926ff6aebfaab8683941e87b9395a0568219c978787a07abc8c962bfbb76f9a06c1f55b3b98f1495d05f7eb53741
7
+ data.tar.gz: 5a5f25872c863997c6878cb15b899df189ead1ed6d83bf4304ddc52fd1ffb94ef18c8425acef2534400cd3b5308454c4fa6afe239e98da11ce06428fc2fc54c3
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  First you need to create a salesforce instance:
24
24
 
25
25
  ```ruby
26
- salesforceintegration = SalesforceIntegration::SalesforceIntegrationLead.new("client_id", "client_secret", "host", "username", "password")
26
+ salesforceintegration = SalesforceIntegration::SalesforceIntegrationLead.new(:client_id => "client_id", :client_secret => "client_secret", :url => "url", :username => "username", :password => "password")
27
27
  ```
28
28
  * client_id and client_secret: See this [link](https://auth0.com/docs/connections/social/salesforce)
29
29
  * host: Use login.salesforce.com or test.salesforce.com if using a sandbox
@@ -34,7 +34,7 @@ salesforceintegration = SalesforceIntegration::SalesforceIntegrationLead.new("cl
34
34
  After salesforceintegration initialized you only need pass the lead's data
35
35
 
36
36
  ```ruby
37
- salesforceintegration.create_lead_on_salesforce("first_name", "last_name", "email", "company", "job_title", "phone", "website")
37
+ salesforceintegration.create_lead_on_salesforce(:first_name => "first_name", :last_name => "last_name", :email => "email", :company => "company", :job_title => "job_title", :phone => "phone", :password => "password")
38
38
  ```
39
39
  This method returns the lead's ID
40
40
 
@@ -1,3 +1,3 @@
1
1
  module Salesforceintegration
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -6,30 +6,34 @@ require 'databasedotcom'
6
6
 
7
7
  module SalesforceIntegration
8
8
  class SalesforceIntegrationLead
9
- def initialize(salesforce_client_id, salesforce_client_secret, salesforce_url, salesforce_username, salesforce_password)
10
- client = Databasedotcom::Client.new(:client_id => salesforce_client_id, :client_secret => salesforce_client_secret, :host => salesforce_url)
11
- client.authenticate(:username => salesforce_username, :password => salesforce_password)
9
+ def initialize(options)
10
+ raise "It's necessary to inform client_id, client_secret, url, username and password!" unless options.has_key?(:client_id) and options.has_key?(:client_secret) and options.has_key?(:url) and options.has_key?(:username) and options.has_key?(:password)
11
+
12
+ client = Databasedotcom::Client.new(:client_id => options[:client_id], :client_secret => options[:client_secret], :host => options[:url])
13
+ client.authenticate(:username => options[:username], :password => options[:password])
12
14
 
13
15
  client.materialize("Lead")
14
16
  client.materialize("User")
15
17
  end
16
18
 
17
19
  #TODO: Permitir associar a contas
18
- #TODO: Validar campos
19
- def create_lead_on_salesforce(first_name, last_name, email, company, job_title, phone, website)
20
+ def create_lead_on_salesforce(fields)
21
+ raise "The fields last_name and company are required" unless fields.has_key?(:last_name) and fields.has_key?(:company)
22
+ raise "The fields last_name and company cannot be blank" if fields[:last_name].blank? or fields[:company].blank?
23
+
20
24
  lead = Lead.new
21
25
 
22
26
  #TODO: Nao esta claro ao que corresponde esse usuario no salesforce. Verificar
23
27
  user = User.first
24
28
  lead['OwnerId'] = user.Id
25
29
 
26
- lead['FirstName'] = first_name
27
- lead['LastName'] = last_name
28
- lead['Email'] = email
29
- lead['Company'] = company
30
- lead['Title'] = job_title
31
- lead['Phone'] = phone
32
- lead['Website'] = website
30
+ lead['FirstName'] = fields[:first_name]
31
+ lead['LastName'] = fields[:last_name]
32
+ lead['Email'] = fields[:email]
33
+ lead['Company'] = fields[:company]
34
+ lead['Title'] = fields[:job_title]
35
+ lead['Phone'] = fields[:phone]
36
+ lead['Website'] = fields[:website]
33
37
  lead['IsConverted'] = false
34
38
  lead['IsUnreadByOwner'] = true
35
39
  lead.save
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salesforceintegration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karla Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-20 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler