email_list_api 0.1.0.rc.5 → 0.1.0.rc.6
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 +4 -4
- data/README.md +14 -8
- data/lib/email_list_api/client.rb +40 -40
- data/lib/email_list_api/syncs_email_list_contact.rb +3 -3
- data/lib/email_list_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd556c4af0aa25954fdad4e7acc5f5c9ef077c182bacb7d395e3145f90ec73fa
|
|
4
|
+
data.tar.gz: 24dce3a08f06f15eb2341972b5cb2f01b8b07e3ae533a871cc6b82c2a6931b3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 113f3a7bc9f3ca2c43797ef5b81578479682f0cb2f300ffd0b633c602b1730e96c270a7df5418a8a8a2035d023f5e3679795729ddd7f380343e485810d2dad46
|
|
7
|
+
data.tar.gz: 5e16ed50c5d2d9ce405f063b649a7986df62fccb0b107ac46c399cfaa6c1863c1a25d7a54c95b6cc6974c36bbfdfbf64a7083d1c142f2b645d6b15c24ccd7ad5
|
data/README.md
CHANGED
|
@@ -54,23 +54,29 @@ client = EmailListApi::Client.new(api_key: 'your_api_key', api_version: 1)
|
|
|
54
54
|
projects = client.projects
|
|
55
55
|
project = client.create_project(name: 'My Project')
|
|
56
56
|
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
# Create or update a project (idempotent)
|
|
58
|
+
project = client.upsert_project(name: 'My Project')
|
|
59
|
+
|
|
60
|
+
# Lists (project must be slug)
|
|
61
|
+
lists = client.lists(project_slug: project['data']['slug'])
|
|
62
|
+
list = client.create_list(project_slug: project['data']['slug'], name: 'Newsletter')
|
|
60
63
|
|
|
61
64
|
# Contacts
|
|
62
|
-
client.create_contact(
|
|
63
|
-
client.update_contact(
|
|
65
|
+
client.create_contact(project_slug: project['data']['slug'], email: 'user@example.com')
|
|
66
|
+
client.update_contact(project_slug: project['data']['slug'], id: contact_id, first_name: 'John')
|
|
64
67
|
# Upsert: creates if new, updates if exists (by email)
|
|
65
|
-
client.upsert_contact(
|
|
68
|
+
contact = client.upsert_contact(project_slug: project['data']['slug'], email: 'user@example.com', first_name: 'Jane')
|
|
69
|
+
# Access response data using string keys
|
|
70
|
+
contact_id = contact['data']['id']
|
|
71
|
+
email = contact['data']['email']
|
|
66
72
|
|
|
67
73
|
# Unsubscribe URLs
|
|
68
74
|
# Contact responses include unsubscribe_urls hash (list_id => unsubscribe_url)
|
|
69
|
-
contact = client.contact(
|
|
75
|
+
contact = client.contact(project_slug: project['data']['slug'], id: contact_id)
|
|
70
76
|
contact['data']['unsubscribe_urls'] # => { 1 => "https://emaillist.dev/unsubscribe/...", 2 => "..." }
|
|
71
77
|
|
|
72
78
|
# List contact responses include unsubscribe_url for that specific list
|
|
73
|
-
list_contacts = client.list_contacts(
|
|
79
|
+
list_contacts = client.list_contacts(project_slug: project['data']['slug'], list_slug: list['data']['slug'])
|
|
74
80
|
list_contacts['data'].each do |contact|
|
|
75
81
|
unsubscribe_url = contact['unsubscribe_url'] # => "https://emaillist.dev/unsubscribe/..."
|
|
76
82
|
# Include this URL in your email templates
|
|
@@ -41,8 +41,8 @@ module EmailListApi
|
|
|
41
41
|
get("projects")
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def project(
|
|
45
|
-
get("projects/#{
|
|
44
|
+
def project(slug:)
|
|
45
|
+
get("projects/#{slug}")
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def create_project(name:, description: nil)
|
|
@@ -53,103 +53,103 @@ module EmailListApi
|
|
|
53
53
|
post("projects/upsert", { project: { name: name, description: description } })
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def update_project(
|
|
56
|
+
def update_project(slug:, name: nil, description: nil)
|
|
57
57
|
params = { project: {} }
|
|
58
58
|
params[:project][:name] = name if name
|
|
59
59
|
params[:project][:description] = description if description
|
|
60
|
-
patch("projects/#{
|
|
60
|
+
patch("projects/#{slug}", params)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def delete_project(
|
|
64
|
-
delete("projects/#{
|
|
63
|
+
def delete_project(slug:)
|
|
64
|
+
delete("projects/#{slug}")
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
# Lists
|
|
68
|
-
def lists(
|
|
69
|
-
get("projects/#{
|
|
68
|
+
def lists(project_slug:)
|
|
69
|
+
get("projects/#{project_slug}/lists")
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
def list(
|
|
73
|
-
get("projects/#{
|
|
72
|
+
def list(project_slug:, slug:)
|
|
73
|
+
get("projects/#{project_slug}/lists/#{slug}")
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
def create_list(
|
|
77
|
-
post("projects/#{
|
|
76
|
+
def create_list(project_slug:, name:, description: nil)
|
|
77
|
+
post("projects/#{project_slug}/lists", { list: { name: name, description: description } })
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
def upsert_list(
|
|
81
|
-
post("projects/#{
|
|
80
|
+
def upsert_list(project_slug:, name:, description: nil)
|
|
81
|
+
post("projects/#{project_slug}/lists/upsert", { list: { name: name, description: description } })
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
def update_list(
|
|
84
|
+
def update_list(project_slug:, slug:, name: nil, description: nil)
|
|
85
85
|
params = { list: {} }
|
|
86
86
|
params[:list][:name] = name if name
|
|
87
87
|
params[:list][:description] = description if description
|
|
88
|
-
patch("projects/#{
|
|
88
|
+
patch("projects/#{project_slug}/lists/#{slug}", params)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
def delete_list(
|
|
92
|
-
delete("projects/#{
|
|
91
|
+
def delete_list(project_slug:, slug:)
|
|
92
|
+
delete("projects/#{project_slug}/lists/#{slug}")
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
# Contacts
|
|
96
|
-
def contacts(
|
|
97
|
-
get("projects/#{
|
|
96
|
+
def contacts(project_slug:, page: 1)
|
|
97
|
+
get("projects/#{project_slug}/contacts", { page: page })
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
def contact(
|
|
101
|
-
get("projects/#{
|
|
100
|
+
def contact(project_slug:, id:)
|
|
101
|
+
get("projects/#{project_slug}/contacts/#{id}")
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
-
def create_contact(
|
|
104
|
+
def create_contact(project_slug:, email:, first_name: nil, last_name: nil)
|
|
105
105
|
params = { contact: { email: email } }
|
|
106
106
|
params[:contact][:first_name] = first_name if first_name
|
|
107
107
|
params[:contact][:last_name] = last_name if last_name
|
|
108
|
-
post("projects/#{
|
|
108
|
+
post("projects/#{project_slug}/contacts", params)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
def update_contact(
|
|
111
|
+
def update_contact(project_slug:, id:, email: nil, first_name: nil, last_name: nil)
|
|
112
112
|
params = { contact: {} }
|
|
113
113
|
params[:contact][:email] = email if email
|
|
114
114
|
params[:contact][:first_name] = first_name if first_name
|
|
115
115
|
params[:contact][:last_name] = last_name if last_name
|
|
116
|
-
patch("projects/#{
|
|
116
|
+
patch("projects/#{project_slug}/contacts/#{id}", params)
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
def upsert_contact(
|
|
119
|
+
def upsert_contact(project_slug:, email:, first_name: nil, last_name: nil)
|
|
120
120
|
params = { contact: { email: email } }
|
|
121
121
|
params[:contact][:first_name] = first_name if first_name
|
|
122
122
|
params[:contact][:last_name] = last_name if last_name
|
|
123
|
-
post("projects/#{
|
|
123
|
+
post("projects/#{project_slug}/contacts/upsert", params)
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
def delete_contact(
|
|
127
|
-
delete("projects/#{
|
|
126
|
+
def delete_contact(project_slug:, id:)
|
|
127
|
+
delete("projects/#{project_slug}/contacts/#{id}")
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
# List Memberships
|
|
131
|
-
def list_contacts(
|
|
132
|
-
get("projects/#{
|
|
131
|
+
def list_contacts(project_slug:, list_slug:)
|
|
132
|
+
get("projects/#{project_slug}/lists/#{list_slug}/contacts")
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
def add_contacts_to_list(
|
|
135
|
+
def add_contacts_to_list(project_slug:, list_slug:, contacts:)
|
|
136
136
|
# contacts can be an array of hashes or a single hash, but API expects array
|
|
137
137
|
contacts = [ contacts ] unless contacts.is_a?(Array)
|
|
138
|
-
post("projects/#{
|
|
138
|
+
post("projects/#{project_slug}/lists/#{list_slug}/contacts", { contacts: contacts })
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
-
def add_contact_to_list(
|
|
141
|
+
def add_contact_to_list(project_slug:, list_slug:, contact_id:)
|
|
142
142
|
# Helper for adding single existing contact by ID
|
|
143
|
-
add_contacts_to_list(
|
|
143
|
+
add_contacts_to_list(project_slug: project_slug, list_slug: list_slug, contacts: [ { id: contact_id } ])
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
def remove_contact_from_list(
|
|
147
|
-
delete("projects/#{
|
|
146
|
+
def remove_contact_from_list(project_slug:, list_slug:, contact_id:)
|
|
147
|
+
delete("projects/#{project_slug}/lists/#{list_slug}/contacts/#{contact_id}")
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
# Bulk Operations
|
|
151
|
-
def bulk_create_contacts(
|
|
152
|
-
post("projects/#{
|
|
151
|
+
def bulk_create_contacts(project_slug:, contacts:)
|
|
152
|
+
post("projects/#{project_slug}/contacts/bulk", { contacts: contacts })
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
private
|
|
@@ -120,15 +120,15 @@ module EmailListApi
|
|
|
120
120
|
|
|
121
121
|
# Upsert contact (creates if new, updates if exists)
|
|
122
122
|
contact = emaillist_client.upsert_contact(
|
|
123
|
-
|
|
123
|
+
project_slug: project_slug,
|
|
124
124
|
email: email,
|
|
125
125
|
first_name: first_name,
|
|
126
126
|
last_name: last_name
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
# Optionally store the contact_id if column exists
|
|
130
|
-
if respond_to?(:emaillist_contact_id=) && contact && contact[
|
|
131
|
-
contact_id = contact[
|
|
130
|
+
if respond_to?(:emaillist_contact_id=) && contact && contact['data']
|
|
131
|
+
contact_id = contact['data']['id']
|
|
132
132
|
update_column(:emaillist_contact_id, contact_id) if persisted? && contact_id
|
|
133
133
|
end
|
|
134
134
|
rescue => e
|