{"id":16087115,"url":"https://github.com/newapplesho/sendgrid-smalltalk","last_synced_at":"2025-03-18T06:30:46.652Z","repository":{"id":35105577,"uuid":"39283885","full_name":"newapplesho/sendgrid-smalltalk","owner":"newapplesho","description":"SendGrid API Libraries for Smalltalk","archived":false,"fork":false,"pushed_at":"2021-07-31T08:16:03.000Z","size":119,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T17:40:18.574Z","etag":null,"topics":["pharo","sendgrid","smalltalk"],"latest_commit_sha":null,"homepage":null,"language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/newapplesho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"newapplesho"}},"created_at":"2015-07-18T02:36:11.000Z","updated_at":"2023-08-01T10:56:30.000Z","dependencies_parsed_at":"2022-08-18T01:55:42.964Z","dependency_job_id":null,"html_url":"https://github.com/newapplesho/sendgrid-smalltalk","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newapplesho%2Fsendgrid-smalltalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newapplesho%2Fsendgrid-smalltalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newapplesho%2Fsendgrid-smalltalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newapplesho%2Fsendgrid-smalltalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newapplesho","download_url":"https://codeload.github.com/newapplesho/sendgrid-smalltalk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244169307,"owners_count":20409696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pharo","sendgrid","smalltalk"],"created_at":"2024-10-09T13:27:54.714Z","updated_at":"2025-03-18T06:30:46.077Z","avatar_url":"https://github.com/newapplesho.png","language":"Smalltalk","funding_links":["https://github.com/sponsors/newapplesho"],"categories":[],"sub_categories":[],"readme":"# SendGrid Smalltalk\n\n[SendGrid](https://sendgrid.com/) client library to send emails very easily using [Pharo](http://pharo.org/) Smalltalk.\n\nForked from [sendgrid-smalltalk](https://github.com/newapplesho/sendgrid-smalltalk).\n\n## Features\n\n### V3\n\n* [V3 API (adding!)](https://sendgrid.com/docs/API_Reference/api_v3.html)\n  * Send\n  * Blocks and Spam report\n  * Substitision, Personalization and Dynamic Templates\n\n### V2 (outdated)\n\n* [Web API's Mail](https://sendgrid.com/docs/API_Reference/Web_API/mail.html)\n* [Marketing Email API](https://sendgrid.com/docs/API_Reference/Marketing_Emails_API/index.html) (supported Categories, Emails, Lists)\n\n## Supported Pharo Versions\n\n* [Pharo](http://pharo.org/) 5.0, 6.0, 6.1\n\n## How to install\n\n```smalltalk\nMetacello new\n    baseline: 'SendGrid';\n    repository: 'github://sorabito/sendgrid-smalltalk/pharo-repository';\n    load.\n```\n\n## How to use\n\n### Basic Mail Send\n\n#### Settings\n\n```smalltalk\nSGSettings default v3ApiKey: 'SG.xxxxxxxxxxxxxxxxx'.\n```\n\n#### Sending a text mail\n\n```smalltalk\nmail := SGMail default.\nmail from: 'foo@example.com'.\nmail fromName: 'Smalltalker'.\nmail to: 'bar@example.com'.\nmail subject:'SendGrid Test Mail'.\nmail text:'My first email through SendGrid. Sent from Pharo Smalltalk.'.\nmail send.\n```\n\n#### Sending a html mail\n\n```smalltalk\nmail := SGMail default.\nmail from: 'foo@example.com'.\nmail fromName: 'Smalltalker'.\nmail to: 'bar@example.com'.\nmail subject:'SendGrid Test Mail'.\nmail html:'\u003ch1\u003eMy first email through SendGrid\u003c/h1\u003e\u003cp\u003eSent from Pharo Smalltalk\u003c/p\u003e'.\nmail send.\n```\n\n\n### Mail Send with Templates\n\nYou can send sophisticated e-mails using registered handlebars templates.\n\n#### Registering a template\n\n```smalltalk\ntemplate := (SGMailTemplate name: 'SampleMail-1') ensureRegistered.\ntemplate ensureVersionNamed: 'v1' setting: [:v | \n\tv subject: '{{event}} ({{date}})'.\n\tv textContent: '\n{{initialGreetings}}!\n\n{{body}}\n---\n{{signature}}'.\n]. \"-\u003e SGMailTemplate('d-18e84a9799fa4885b11d34a84e9e2384','SampleMail-1')\"\n```\n\n#### Getting templates\n\n```smalltalk\nmail := SGMail default.\nmail allDynamicTemplates. \"-\u003e an Array(SGMailTemplate('d-18e84a9799fa4885b11d34a84e9e2384','SampleMail-1'))\"\n\nmailTemplate := mail templateNamed: 'SampleMail-1'.\nmailTemplate versions. \"-\u003e  an OrderedCollection(*SGMailTemplateVersion('c255155a-8fc5-471b-82cf-6e5192073245','v1'))\"\nmailTemplateVersion := mailTemplate activeVersion. \" -\u003e *SGMailTemplateVersion('c255155a-8fc5-471b-82cf-6e5192073245','v1')\"\nmailTemplateVersion loadContents textContent. \"-\u003e returns a template text content registered above\"\n```\n\n#### Sending an aggregated mail with two personalizations\n\n```smalltalk\nmail := SGMail forDynamicTemplate.\nmail fromName: 'Info'.\nmail from: 'info@softumeya.com'.\nmail addPersonalizationDo: [ :p |\n\tp addToEntryDo: [ :ent | ent address: 'aaa@aaa.com'; name: 'AAA'].\n\tp templateData:  { \n\t\t'event' -\u003e 'Smalltalk-meetup'.\n\t\t'date' -\u003e '2019/03/10'.\n\t\t'initialGreetings' -\u003e ('Hello ', p to first name).\n\t\t'body' -\u003e 'aaaaa'.\n\t\t'signature' -\u003e '[:masashi | ^umezawa]'.\n\t} asDictionary \n].\nmail addPersonalizationDo: [ :p |\n\tp addToEntryDo: [ :ent | ent address: 'bbb@bbb.com'; name: 'BBB'].\n\tp templateData:  { \n\t\t'event' -\u003e 'Smalltalk-auction'.\n\t\t'date' -\u003e '2019/03/12'.\n\t\t'initialGreetings' -\u003e ('Hello ', p to first name).\n\t\t'body' -\u003e 'bbbbb'.\n\t\t'signature' -\u003e '-- MU'.\n\t} asDictionary \n].\nmail sendByTemplateNamed: 'SampleMail-1'. \n```\n\n### Marketing Email API (V2)\n\n#### Lists\n\n##### add\n\n```smalltalk\nsg := (SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password').\nsg add:'foobar'. \"print it ==\u003e  a JsonObject('message'-\u003e'success' )\"\n```\n\n##### edit\n\n```smalltalk\nsg := (SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password').\nsg renameListFrom: 'foobar' to: 'foobar2'. \n```\n\n##### get\n\n```smalltalk\n(SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') get.\n```\n\n##### delete\n\n```smalltalk\n(SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') \n\tdelete:'foobar'.\n```\n\n\n#### Emails\n\n##### add\n\n```smalltalk\njson := JsonObject new.\njson at:'name' put:'test'.\njson at:'email' put:'foobar@example.com'.\n\n(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') \n\tlist: 'foobar'; \n\tdatum: (Array with: json asJsonString); add.\n```\n\n##### get\n\n```smalltalk\n(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') \n\tlist: 'foobar'; get.\n```\n\n##### count\n\n```smalltalk\n(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') \n\tlist: 'foobar'; count.\n```\n\n##### delete\n\n```smalltalk\n(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') \n list: 'foobar';\n email:'foobar@example.com'; \n delete.\n```\n\n#### Categories\n\n```smalltalk\n(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') list.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewapplesho%2Fsendgrid-smalltalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewapplesho%2Fsendgrid-smalltalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewapplesho%2Fsendgrid-smalltalk/lists"}