Skip to content

Commit

Permalink
Updating examples to not provide event id (#13)
Browse files Browse the repository at this point in the history
* Updating examples to not provide event id

* Updating comment in proto file

* Fix typo
  • Loading branch information
sidd0610 authored Jun 24, 2022
1 parent f4d4efd commit d053d08
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
4 changes: 0 additions & 4 deletions go/grpcclient/grpcclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/developerforce/pub-sub-api-pilot/go/common"
"github.com/developerforce/pub-sub-api-pilot/go/oauth"
"github.com/developerforce/pub-sub-api-pilot/go/proto"
"github.com/google/uuid"
"github.com/linkedin/goavro/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -262,7 +261,6 @@ func (c *PubSubClient) Publish(schema *proto.SchemaInfo) error {
TopicName: common.TopicName,
Events: []*proto.ProducerEvent{
{
Id: uuid.New().String(),
SchemaId: schema.GetSchemaId(),
Payload: payload,
},
Expand Down Expand Up @@ -324,7 +322,6 @@ func (c *PubSubClient) PublishStream(schema *proto.SchemaInfo) error {
TopicName: common.TopicName,
Events: []*proto.ProducerEvent{
{
Id: uuid.New().String(),
SchemaId: schema.GetSchemaId(),
Payload: payload,
},
Expand Down Expand Up @@ -389,7 +386,6 @@ func (c *PubSubClient) PublishStream(schema *proto.SchemaInfo) error {
TopicName: common.TopicName,
Events: []*proto.ProducerEvent{
{
Id: uuid.New().String(),
SchemaId: schema.GetSchemaId(),
Payload: payload,
},
Expand Down
2 changes: 1 addition & 1 deletion pubsub_api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ message EventHeader {
* Event value that is created by an event producing application.
*/
message ProducerEvent {
// The event's guid
// The event's system generated guid
string id = 1;
// Schema fingerprint for this event which is hash of the schema
string schema_id = 2;
Expand Down
1 change: 0 additions & 1 deletion python/InventoryAppExample/InventoryApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def generate_producer_events(schema_id, record_id, obj):
"EstimatedDeliveryDate__c": int(dt.timestamp()),
"Weight__c": 58.2}
req = {
"id": "234",
"schema_id": schema_id,
"payload": obj.encode(schema, payload),
}
Expand Down
9 changes: 4 additions & 5 deletions python/InventoryAppExample/PubSub.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def auth(self):
res.__dict__)

# Set metadata headers
self.metadata = (('x-sfdc-api-session-token', self.session_id),
('x-sfdc-instance-url', self.url),
('x-sfdc-tenant-id', self.tenant_id))
self.metadata = (('accesstoken', self.session_id),
('instanceurl', self.url),
('tenantid', self.tenant_id))

def make_fetch_request(self, topic):
"""
Expand Down Expand Up @@ -166,10 +166,9 @@ def generate_producer_events(self, schema, schema_id):
payload = {
"CreatedDate": int(datetime.now().timestamp()),
"CreatedById": '005R0000000cw06IAA', # Your user ID
"textt__c": 'text ==t Hello World'
"textt__c": 'Hello World'
}
req = {
"id": "261", # This can be anything
"schema_id": schema_id,
"payload": self.encode(schema, payload)
}
Expand Down
2 changes: 1 addition & 1 deletion python/InventoryAppExample/SalesforceListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def process_confirmation(event, pubsub):
time.sleep(2)
day = datetime.fromtimestamp(decoded['EstimatedDeliveryDate__c']).strftime('%Y-%m-%d')
res = requests.patch(my_url + "/services/data/v52.0/sobjects/Opportunity/"
+ decoded['OpptyRecordId__c'], json.dumps({"EstimatedDeliveryDate__c": day}),
+ decoded['OpptyRecordId__c'], json.dumps({"Description": "Estimated Delivery Date: " + day}),
headers={"Authorization": "Bearer " + pubsub.session_id,
"Content-Type": "application/json"})
print(" Done!", res)
Expand Down

0 comments on commit d053d08

Please sign in to comment.