Skip to content

Commit

Permalink
Map AccountNumber to wombat customer ID
Browse files Browse the repository at this point in the history
  • Loading branch information
huoxito committed Oct 27, 2014
1 parent 56eccc8 commit 4aa8af3
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 56 deletions.
1 change: 1 addition & 0 deletions lib/SF_services/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def latest_updates(time = Time.now.utc.iso8601)
"Contact.Lastname",
"Contact.Email",
"Contact.Account.Name",
"Contact.Account.AccountNumber",
"Contact.Account.BillingCity",
"Contact.Account.BillingCountry",
# "Contact.Account.BillingCountryCode",
Expand Down
3 changes: 2 additions & 1 deletion lib/integrations/builders/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def initialize(object)

def build
params = {
'Name' => name
'Name' => name,
'AccountNumber' => object['id']
}
end

Expand Down
4 changes: 2 additions & 2 deletions lib/integrations/contact_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def fetch_updates
account = contact["Account"] || {}

{
id: contact["Id"],
id: account["AccountNumber"] || contact["Id"],
first_name: contact["FirstName"],
last_name: contact["LastName"],
email: contact["Email"],
account_name: contact["Account"]["Name"],
account_name: account["Name"],
salesforce_id: contact["Id"],
shipping_address: build_address(account, "Shipping"),
billing_address: build_address(account)
Expand Down
54 changes: 27 additions & 27 deletions spec/cassettes/requests/update_customer.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions spec/lib/integrations/builders/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

it 'returns hash with address data' do
expect(result).to be_kind_of Hash
expect(result.keys).to eq(
["Name"]
)
expect(result.keys).to eq ["Name", "AccountNumber"]
end
end
end
2 changes: 1 addition & 1 deletion spec/salesforce_endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
payload = Factories.add_customer_payload.merge(parameters: config)
email = payload['customer']['email']

VCR.use_cassette "requests/add_customer" do
VCR.use_cassette "requests/1414442508" do
post "/add_customer", payload.to_json, auth
expect(json_response["summary"]).to match "#{email} updated in Salesforce"
expect(last_response.status).to eq 200
Expand Down
44 changes: 22 additions & 22 deletions spec/support/factories/add_customer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"request_id": "52f367367575e449c3000001",
"customer": {
"id": "a123",
"firstname": "Brian",
"lastname": "Smith",
"email": "[email protected]",
"shipping_address": {
"address1": "1234 Awesome Street",
"address2": "",
"zipcode": "90210",
"city": "Hollywood",
"state": "California",
"country": "US",
"phone": "0000000000"
},
"billing_address": {
"address1": "1234 Awesome Street",
"address2": "",
"zipcode": "90210",
"city": "Hollywood",
"state": "California",
"country": "US",
"phone": "0000000000"
"id": "b435232435",
"firstname": "Washington",
"lastname": "Smith",
"email": "[email protected]",
"shipping_address": {
"address1": "1234 Awesome Street",
"address2": "",
"zipcode": "90210",
"city": "Hollywood",
"state": "California",
"country": "US",
"phone": "0000000000"
},
"billing_address": {
"address1": "1234 Awesome Street",
"address2": "",
"zipcode": "90210",
"city": "Hollywood",
"state": "California",
"country": "US",
"phone": "0000000000"
}
}
}
}

0 comments on commit 4aa8af3

Please sign in to comment.