Skip to content

Commit

Permalink
Version 2.0: MailchimpSDK.swift to Mailchimp.swift (#51)
Browse files Browse the repository at this point in the history
* Renamed MailchimpSDK class to Mailchimp.
  • Loading branch information
jey-starratt authored Nov 11, 2020
1 parent 0559a66 commit 9413b87
Show file tree
Hide file tree
Showing 83 changed files with 4,676 additions and 1,253 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0] - 2020-11-11
### Changed
- Renamed MailchimpSDK class to Mailchimp to avoid ambiguity.

## [1.0] - 2020-07-20
### Changed
- Bumped version to 1.0
Expand Down
2 changes: 1 addition & 1 deletion MailchimpSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'MailchimpSDK'
s.version = '1.0'
s.version = '2.0'
s.summary = 'Mailchimp SDK for iOS'

s.description = <<-DESC
Expand Down
16 changes: 8 additions & 8 deletions MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
BFF30D7F2371FB3D005FAABC /* ContactOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFF30D7E2371FB3D005FAABC /* ContactOperation.swift */; };
F239C3FD229F2DDF00FB85C3 /* CountryCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = F239C3FC229F2DDF00FB85C3 /* CountryCode.swift */; };
F26745E522F89DAC00AD1E93 /* ContactTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F26745E422F89DAC00AD1E93 /* ContactTests.swift */; };
F288D79E2289BBD7004CB563 /* MailchimpSDK.swift in Sources */ = {isa = PBXBuildFile; fileRef = F288D79D2289BBD7004CB563 /* MailchimpSDK.swift */; };
F288D79E2289BBD7004CB563 /* Mailchimp.swift in Sources */ = {isa = PBXBuildFile; fileRef = F288D79D2289BBD7004CB563 /* Mailchimp.swift */; };
F2A2203122984C7600F57058 /* MergeFieldTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2A2203022984C7600F57058 /* MergeFieldTests.swift */; };
F2AFC4D022947FFB006C742B /* MergeField.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2AFC4CF22947FFB006C742B /* MergeField.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -64,7 +64,7 @@
BFF30D7E2371FB3D005FAABC /* ContactOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactOperation.swift; sourceTree = "<group>"; };
F239C3FC229F2DDF00FB85C3 /* CountryCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryCode.swift; sourceTree = "<group>"; };
F26745E422F89DAC00AD1E93 /* ContactTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactTests.swift; sourceTree = "<group>"; };
F288D79D2289BBD7004CB563 /* MailchimpSDK.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MailchimpSDK.swift; path = SDK/MailchimpSDK.swift; sourceTree = "<group>"; };
F288D79D2289BBD7004CB563 /* Mailchimp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Mailchimp.swift; path = SDK/Mailchimp.swift; sourceTree = "<group>"; };
F2A2203022984C7600F57058 /* MergeFieldTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MergeFieldTests.swift; sourceTree = "<group>"; };
F2AFC4CF22947FFB006C742B /* MergeField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MergeField.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -111,7 +111,7 @@
children = (
B95896B222774CA100F7509B /* Core */,
B95896B122774C9A00F7509B /* SDK */,
F288D79D2289BBD7004CB563 /* MailchimpSDK.swift */,
F288D79D2289BBD7004CB563 /* Mailchimp.swift */,
B958969A22774C0C00F7509B /* MailchimpSDK.h */,
B958969B22774C0C00F7509B /* Info.plist */,
);
Expand Down Expand Up @@ -336,7 +336,7 @@
B95896CA2280BA8700F7509B /* ContactRequest.swift in Sources */,
F2AFC4D022947FFB006C742B /* MergeField.swift in Sources */,
B95896D02281FD2D00F7509B /* PostBody.swift in Sources */,
F288D79E2289BBD7004CB563 /* MailchimpSDK.swift in Sources */,
F288D79E2289BBD7004CB563 /* Mailchimp.swift in Sources */,
BFD503FB2369DA4500939748 /* EventRequest.swift in Sources */,
B95896BD227768AB00F7509B /* APIRequest.swift in Sources */,
B95896B82277689F00F7509B /* URLRequest.swift in Sources */,
Expand Down Expand Up @@ -511,7 +511,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.theRocketScienceGroup.MailchimpSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -540,7 +540,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.theRocketScienceGroup.MailchimpSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand All @@ -560,7 +560,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.theRocketScienceGroup.Mailchimp-SDKTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -579,7 +579,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.theRocketScienceGroup.Mailchimp-SDKTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion MailchimpSDK/MailchimpSDK/Core/Networking/PostBody.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PostBody.swift
// Mailchimp SDK
// MailchimpSDK
//
// Created by Michael Patzer on 5/7/19.
// Copyright 2019 The Rocket Science Group LLC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// MailchimpSDK.swift
// Mailchimp SDK
// Mailchimp.swift
// MailchimpSDK
//
// Created by Chez Browne on 5/13/19.
// Copyright 2019 The Rocket Science Group LLC
Expand All @@ -18,8 +18,7 @@
import Foundation

/// Provides an interface for storing user behavior in Mailchimp
///
public class MailchimpSDK: NSObject {
public class Mailchimp: NSObject {
public enum InitError: Error { case invalidToken(String) }

/// Automatically tags contacts with basic device information when created or updated. On by default.
Expand Down Expand Up @@ -51,8 +50,8 @@ public class MailchimpSDK: NSObject {
}

api = AnzeeAPI(token: token)
MailchimpSDK.autoTagContacts = autoTagContacts
MailchimpSDK.debugMode = debugMode
Mailchimp.autoTagContacts = autoTagContacts
Mailchimp.debugMode = debugMode

if debugMode {
print("Mailchimp SDK Initialized. Version: \(version)")
Expand Down
2 changes: 1 addition & 1 deletion MailchimpSDK/MailchimpSDK/SDK/Models/Contact.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Contact.swift
// Mailchimp SDK
// MailchimpSDK
//
// Created by Michael Patzer on 5/6/19.
// Copyright 2019 The Rocket Science Group LLC
Expand Down
2 changes: 1 addition & 1 deletion MailchimpSDK/MailchimpSDK/SDK/Models/CountryCode.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// CountryCode.swift
// Mailchimp SDK
// MailchimpSDK
//
// Created by Chez Browne on 5/29/19.
// Copyright 2019 The Rocket Science Group LLC
Expand Down
2 changes: 1 addition & 1 deletion MailchimpSDK/MailchimpSDK/SDK/Models/MergeField.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// MergeField.swift
// Mailchimp SDK
// MailchimpSDK
//
// Created by Chez Browne on 5/21/19.
// Copyright 2019 The Rocket Science Group LLC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import Foundation
public class ContactOperation: Operation {
let contact: Contact
var request: ContactRequest?
let result: MailchimpSDK.RequestCallback?
let result: Mailchimp.RequestCallback?
public var dataTask: URLSessionDataTask?

init(_ contact: Contact, result: MailchimpSDK.RequestCallback? = nil) {
init(_ contact: Contact, result: Mailchimp.RequestCallback? = nil) {
self.contact = contact
self.result = result
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public class ContactOperation: Operation {
request = ContactRequest(contact: contact) { requestResult in
self.result?(requestResult)

if MailchimpSDK.debugMode {
if Mailchimp.debugMode {
switch requestResult {
case .success:
print("Contact request succeeded.")
Expand All @@ -85,7 +85,7 @@ public class ContactOperation: Operation {
self.state = .finished
}

self.dataTask = MailchimpSDK.api?.process(request: request!)
self.dataTask = Mailchimp.api?.process(request: request!)
}
}
}
8 changes: 4 additions & 4 deletions MailchimpSDK/MailchimpSDK/SDK/Operations/EventOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import Foundation
public class EventOperation: Operation {
let event: Event
var request: EventRequest?
let result: MailchimpSDK.RequestCallback?
let result: Mailchimp.RequestCallback?
public var dataTask: URLSessionDataTask?

init(_ event: Event, result: MailchimpSDK.RequestCallback? = nil) {
init(_ event: Event, result: Mailchimp.RequestCallback? = nil) {
self.event = event
self.result = result
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public class EventOperation: Operation {
request = EventRequest(event: event) { requestResult in
self.result?(requestResult)

if MailchimpSDK.debugMode {
if Mailchimp.debugMode {
switch requestResult {
case .success:
print("Event request succeeded.")
Expand All @@ -85,7 +85,7 @@ public class EventOperation: Operation {
self.state = .finished
}

self.dataTask = MailchimpSDK.api?.process(request: request!)
self.dataTask = Mailchimp.api?.process(request: request!)
}
}
}
8 changes: 4 additions & 4 deletions MailchimpSDK/MailchimpSDK/SDK/Requests/ContactRequest.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ContactRequest.swift
// Mailchimp SDK
// MailchimpSDK
//
// Created by Michael Patzer on 5/6/19.
// Copyright 2019 The Rocket Science Group LLC
Expand All @@ -25,10 +25,10 @@ struct ContactRequest: APIRequest {
var apiPath: String { return "clientapi/1.0/contacts" }

/// Callback once API request is complete.
public var callback: MailchimpSDK.RequestCallback?
public var callback: Mailchimp.RequestCallback?


init(contact: Contact, _ callback: MailchimpSDK.RequestCallback? = nil) {
init(contact: Contact, _ callback: Mailchimp.RequestCallback? = nil) {
self.contact = contact
self.callback = callback
}
Expand All @@ -38,7 +38,7 @@ struct ContactRequest: APIRequest {
}

func headers() -> [String : String]? {
return ["Mailchimp-SDK-Version": MailchimpSDK.version, "Mailchimp-SDK-Platform": "iOS"]
return ["Mailchimp-SDK-Version": Mailchimp.version, "Mailchimp-SDK-Platform": "iOS"]
}

func httpVerb() -> HTTPVerb {
Expand Down
6 changes: 3 additions & 3 deletions MailchimpSDK/MailchimpSDK/SDK/Requests/EventRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ struct EventRequest: APIRequest {
var apiPath: String { return "clientapi/1.0/contacts/events" }

/// Callback once API request is complete.
public var callback: MailchimpSDK.RequestCallback?
public var callback: Mailchimp.RequestCallback?


init(event: Event, _ callback: MailchimpSDK.RequestCallback? = nil) {
init(event: Event, _ callback: Mailchimp.RequestCallback? = nil) {
self.event = event
self.callback = callback
}
Expand All @@ -38,7 +38,7 @@ struct EventRequest: APIRequest {
}

func headers() -> [String : String]? {
return ["Mailchimp-SDK-Version": MailchimpSDK.version, "Mailchimp-SDK-Platform": "iOS"]
return ["Mailchimp-SDK-Version": Mailchimp.version, "Mailchimp-SDK-Platform": "iOS"]
}

func httpVerb() -> HTTPVerb {
Expand Down
6 changes: 3 additions & 3 deletions MailchimpSDK/MailchimpSDKTests/Audience/ContactTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ContactTests: XCTestCase {
var token = "PUT YOUR API TOKEN HERE"

override func setUp() {
try? MailchimpSDK.initialize(token: token)
try? Mailchimp.initialize(token: token)
}

func testContactStatus() {
Expand All @@ -37,7 +37,7 @@ class ContactTests: XCTestCase {

func testSetContactStatus() {
let mockApi = MockAnzeeAPI()
MailchimpSDK.api = mockApi
Mailchimp.api = mockApi
let testEmailAddress = "[email protected]"
let testStatus = Contact.Status.subscribed

Expand All @@ -56,7 +56,7 @@ class ContactTests: XCTestCase {

XCTAssertEqual(Contact.Status.subscribed, status)
}
MailchimpSDK.setContactStatus(emailAddress: testEmailAddress, status: testStatus)
Mailchimp.setContactStatus(emailAddress: testEmailAddress, status: testStatus)
}

func testMarketingPermissions() {
Expand Down
14 changes: 7 additions & 7 deletions MailchimpSDK/MailchimpSDKTests/Audience/MergeFieldTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AudienceTests.swift
// Mailchimp SDKTests
// MergeFieldTests.swift
// MailchimpSDKTests
//
// Created by Chez Browne on 5/24/19.
// Copyright 2019 The Rocket Science Group LLC
Expand All @@ -23,7 +23,7 @@ class MergeFieldTests: XCTestCase {
var token = "PUT YOUR API TOKEN HERE"

override func setUp() {
try? MailchimpSDK.initialize(token: token)
try? Mailchimp.initialize(token: token)
}

func testMergeFields() {
Expand All @@ -45,7 +45,7 @@ class MergeFieldTests: XCTestCase {

func testCustomMergeFieldString() {
let mockApi = MockAnzeeAPI()
MailchimpSDK.api = mockApi
Mailchimp.api = mockApi

mockApi.verifyRequest = { request in
guard let contact = request?.contact else {
Expand All @@ -72,12 +72,12 @@ class MergeFieldTests: XCTestCase {

let fieldName = "Genre"
let favoriteGenre = "Action"
MailchimpSDK.setMergeField(emailAddress: "[email protected]", name: fieldName, value: favoriteGenre)
Mailchimp.setMergeField(emailAddress: "[email protected]", name: fieldName, value: favoriteGenre)
}

func testCustomMergeFieldAddress() {
let mockApi = MockAnzeeAPI()
MailchimpSDK.api = mockApi
Mailchimp.api = mockApi

mockApi.verifyRequest = { request in
guard let contact = request?.contact else {
Expand Down Expand Up @@ -115,7 +115,7 @@ class MergeFieldTests: XCTestCase {
state: "GA",
zipCode: "30308",
country: CountryCode.USA)
MailchimpSDK.setMergeField(emailAddress: "[email protected]", name: fieldName, address: address)
Mailchimp.setMergeField(emailAddress: "[email protected]", name: fieldName, address: address)
}

// MockAnzeeAPI in a class since it's self-mutating
Expand Down
Loading

0 comments on commit 9413b87

Please sign in to comment.