Skip to content

Commit

Permalink
Merge pull request #12 from mention-me/fix-segment-not-passed-to-entr…
Browse files Browse the repository at this point in the history
…y-point

Fix segment not passed to entry point
  • Loading branch information
matiasm authored Jan 17, 2023
2 parents 37f6ae4 + 4d27fa4 commit 4bac6b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
20 changes: 14 additions & 6 deletions Example/MentionmeSwift/EnrolReferrerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ class EnrolReferrerViewController: UIViewController {

configureUI()

checkIfReferrerCanEnrol()
// There are two APIs you can use. The EntryPoint is the easiest to get started with - it returns a URL
// to render the Mention Me journey.
// You don't need to call this if you're using the Consumer API. We've left it in as a demo!
callEntryPointApiEnrollment()
// Alternatively, the Consumer API gives you the building blocks to assemble your own UI.
callConsumerApiEnrollment()
}

func configureUI() {
Expand All @@ -52,19 +57,22 @@ class EnrolReferrerViewController: UIViewController {

}

func checkIfReferrerCanEnrol() {
func callEntryPointApiEnrollment() {
let parameters = MentionmeCustomerParameters(
emailAddress: email, firstname: firstname, surname: surname)
parameters.segment = segment

let request = MentionmeReferrerEnrollmentRequest(mentionmeCustomerParameters: parameters)

//Check if the enrollment can even happen before trying to enrol the referrer
Mentionme.shared.entryPointForReferrerEnrollment(
mentionmeReferrerEnrollmentRequest: MentionmeReferrerEnrollmentRequest(mentionmeCustomerParameters: parameters),
mentionmeReferrerEnrollmentRequest: request,
situation: "app-check-enrol-referrer",
success: { (url, defaultCallToActionString) in

//if success then enrol referrer
self.enrolReferrer()
// If successful, you can now use the URL and the Call to Action in your UI.
print(url)
print(defaultCallToActionString)

},
failure: { (error) in
Expand All @@ -81,7 +89,7 @@ class EnrolReferrerViewController: UIViewController {
}
}

func enrolReferrer() {
func callConsumerApiEnrollment() {

//Creating customer parameters with email , firstname and surname
let parameters = MentionmeCustomerParameters(
Expand Down
2 changes: 1 addition & 1 deletion MentionmeSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'MentionmeSwift'
s.version = '2.0'
s.version = '2.1'
s.summary = 'Supercharge your customer growth with referral marketing through Mention Me'

# This description is used to generate tags and improve search results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,14 @@

import Foundation

public class MentionmeReferrerEnrollmentRequest: MentionmeRequest {

override init() {
super.init()
}
public class MentionmeReferrerEnrollmentRequest: MentionmeCustomerRequest {

public convenience init(mentionmeCustomerParameters: MentionmeCustomerParameters) {

self.init()

super.method = MethodType.post
super.urlSuffix = "referrer"
super.urlEndpoint = "entry-point"

super.mentionmeCustomerParameters = mentionmeCustomerParameters
}

func createBodyParameters() {
bodyParameters = [String: Any]()
}

override func createRequest(requestParameters: MentionmeRequestParameters) -> NSMutableURLRequest
{
createBodyParameters()
return super.createRequest(requestParameters: requestParameters)
}

}

0 comments on commit 4bac6b7

Please sign in to comment.