Skip to content

Instantly share code, notes, and snippets.

@daimagine
Forked from fadliawan/campur.js
Last active September 28, 2016 14:24
Show Gist options
  • Save daimagine/b63378317329a759a7e3efc3080ea98f to your computer and use it in GitHub Desktop.
Save daimagine/b63378317329a759a7e3efc3080ea98f to your computer and use it in GitHub Desktop.
Asura + Wyvern
// Asura (CustomerController.js)
static async postCustomerWithMagic(ctx, next) {
// .. something something
} else if (primary_id_type === 'customerId') {
let { isActive, isProvisioned } = await api.classify(primary_id, primary_id_type);
if (!isActive && !isProvisioned) {
await api.provision(customer.id, 'spAccountId', customer.sku, effectiveDate, primary_id);
}
} else {
// .. something something
ctx.json(result);
}
// Wyvern (SignupController.js)
*prePostOtp()
{
// do something
var classify = .. do classification
if (isActive || isLapsed) {
// call another asura endpoint
// which will move SKU instead of provision and create user
return;
}
// do something else
}
*postOtp()
{
var activationResult = yield postCustomer(this.session.country, this.request.body);
// create user
var customerParam = {
ipAddress: process.env[this.session.country + '_CREDENTIALS_API_IP'],
apiuser: process.env.EVERGENT_API_USER,
apipassword: process.env.EVERGENT_API_PASSWORD,
contactUserName: this.request.body.email,
contactPassword: this.request.body.password,
phoneNumber: sanitizePhone(this.request.body.phone),
smsCode: this.request.body.otp, // <--- for primaryIdType === 'msisdn' || 'email'
socialLoginID: this.request.body.socialid || null,
socialLoginType: this.request.body.socialid ? 'Facebook' : null,
channelPartnerID: this.request.body.cpid || process.env[this.session.country + '_CREDENTIALS_API_PARTNERID'],
locale: process.env.EVERGENT_API_LOCALE
},
response = yield request.post({ url: process.env.EVERGENT_API_DOMAIN + 'createCustomer', form: customerParam });
response = JSON.parse(response.body);
// .. something something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment