Docusign SOAP PHP API breaks with Fatal Error: Cannot redeclare class - docusignapi

I downloaded the DocuSign API and input my credentials, but when running an example, the API client dies because of class redeclarations.
It seems like the PHP API is just broken... but I see no similar questions about it on SO.
I commented out a bunch of declarations to get it to run. Has anyone else experienced this or know anything about it?
APIService.php
class EnvelopeEventStatusCode {
const Sent = 'Sent';
const Delivered = 'Delivered';
const Completed = 'Completed';
const Declined = 'Declined';
const Voided = 'Voided';
}
class EnvelopeEventStatusCode {
const Sent = 'Sent';
const Delivered = 'Delivered';
const Completed = 'Completed';
const Declined = 'Declined';
const AutoResponded = 'AutoResponded';
const AuthenticationFailed = 'AuthenticationFailed';
}

Don't use the code snippets. Do Use DocuSign Sample folder files instead and open Index.php to test it out.
It happens to me when I was developing.

Related

How to pass tokenID to queryFilter provided by ethers in ERC1155 standard?

I want to get all the transfers from block_B to block_B but for specific token.
I have faced similar issue while trying to get ERC721 transfers.
It looked like this:
const contract = new ethers.
const filter = contract.filters.Transfer();
const events = await contract.queryFilters(filter, block_A, block_B);

getting a parse error and cannot find eslint file

I've realized that you can't send messages directly from the client with the FCM v1 API so now I'm using node.js and I wan't to deploy this cloud function, but I am getting a parse error like so:
This is my function:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const { event } = require("firebase-functions/lib/providers/analytics");
admin.initializeApp(functions.config().firebase);
exports.sendNotificationsToTopic =
functions.firestore.document("school_users/{uid}/events/{docID}").onWrite(async (event) => {
let docID = event.after.id;
let schoolID = event.after.get("school_id")
let title = "New Event!!"
let notificationBody = "A new event has been added to the dashboard!!"
var message = {
notification: {
title: title,
body: notificationBody,
},
topic: schoolID,
};
let response = await admin.messaging().sendToTopic(message);
console.log(response);
});
I did some research and found people were getting similar errors with their projects, and answers were saying to update the version of eslint so it picks up on the shorthand syntax, I can't figure out where to find the eslint file to update the version. Does anybody know where I can find this file?
All I needed to do was show my hidden files in my functions directory. Once I seen the .eslintrc.js file, I simply removed a part of a value from the "eslint" key, and the function deployed perfectly fine.

Twilio nodejs undefined messages create

I'm trying to send SMS using Twilio nodejs (with Typescript) but, for some reason, I cannot access to create method on messages property (as described in the documentation).
const TWILIO_CLIENT = require('twilio');
let twilioClient = new TWILIO_CLIENT(accountSid, authToken);
let result = await twilioClient.messages.create(smsData);
I get a undefined when trying to access create method, and when I log messages endpoint it only shows my the defined accountSid: { accountSid: "..." }
What could it be?

How to add credentials to Google text to speech API?

I am new to Python.I want to use Google text-to-speech API for that i used below code, but I am unable to access the API due to error. This is the code,
def synthesize_text(text):
"""Synthesizes speech from the input string of text."""
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
input_text = texttospeech.types.SynthesisInput(text=text)
# Note: the voice can also be specified by name.
# Names of voices can be retrieved with client.list_voices().
voice = texttospeech.types.VoiceSelectionParams(
language_code='en-US',
ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)
audio_config = texttospeech.types.AudioConfig(
audio_encoding=texttospeech.enums.AudioEncoding.MP3)
response = client.synthesize_speech(input_text, voice, audio_config)
# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
out.write(response.audio_content)
print('Audio content written to file "output.mp3"')
This is the error,
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or
explicitly create credential and re-run the application. For more
information, please see
https://developers.google.com/accounts/docs/application-default-credentials.
I already have credentials JSON file, but I am unable to configure the code to authenticate my request.
Please help!
You could try this code:
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file('yourkey.json')
client = texttospeech.TextToSpeechClient(credentials=credentials)
There are 2 ways :
1 Way :
if you using Json file then better to set json path into Environment Variable, if you do this then you no need to setup in coding it will automatically get you license from there
GOOGLE_APPLICATION_CREDENTIALS=[path]
2 WAY :
I have Java code i don't know about python so you can get idea from here :
String jsonPath = "file.json";
CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(new FileInputStream(jsonPath)));
TextToSpeechSettings settings = TextToSpeechSettings.newBuilder().setCredentialsProvider(credentialsProvider).build();
Instantiates a client
TextToSpeechClient textToSpeechClient = TextToSpeechClient.create(settings)
this seems to be an old discussion but I thought to comment, maybe someone will come across like in my case :))
for nodejs client, I managed to authenticate it this way:
const client = new textToSpeech.TextToSpeechClient({
credentials: {
private_key: "??",
client_email: "???",
}
});
You could authenticate your google credential by different ways.
One is by setting OS environment and another one is authenticate while you initiate a request.
I would suggest oauth2client library for python to authenticate.
In addition to this refer my example on Github (Link).
You need to have a service account, and service account .json key File.
You need to pass the key file name while you creating the client Instance.
const client = new textToSpeech.TextToSpeechClient({
keyFilename: "./auth.json",
});
Download the key file and rename it as auth.json place it root of your project folder.
Make sure Your service account have proper access to call the API.
Here is the full code:
// Imports the Google Cloud client library
const textToSpeech = require("#google-cloud/text-to-speech");
// Import other required libraries
const fs = require("fs");
const util = require("util");
// Creates a client
const client = new textToSpeech.TextToSpeechClient({
keyFilename: "./auth.json",
});
async function quickStart() {
// The text to synthesize
const text = "Hello this is a test";
// Construct the request
const request = {
input: { text: text },
// Select the language and SSML voice gender (optional)
voice: { languageCode: "en-US", ssmlGender: "NEUTRAL" },
// select the type of audio encoding
audioConfig: { audioEncoding: "MP3" },
};
// Performs the text-to-speech request
const [response] = await client.synthesizeSpeech(request);
// Write the binary audio content to a local file
const writeFile = util.promisify(fs.writeFile);
await writeFile("output.mp3", response.audioContent, "binary");
console.log("Audio content written to file: output.mp3");
}
quickStart();

Azure SendGrid DeliverAsync works but not Deliver

I wired up SendGrid using their documentation as a guide. Nothing fancy here, just want to fire off an email for certain events. Looking at the code below, the SendGrid documentation directs me to use transportWeb.Deliver(message) but this results in "cannot resolve symbol Deliver" However if I use DeliverAsync everything works fine. Just seems sloppy to define a variable that is never used.
SendGridMessage message = new SendGridMessage();
message.AddTo(to);
message.From = new MailAddress(from);
message.Subject = subject;
message.Text = body;
var uid = AppConfigSettings.SendGridUid;
var pw = AppConfigSettings.SendGridPw;
var credentials = new NetworkCredential(uid, pw);
var transportWeb = new Web(credentials);
// transportWeb.Deliver(message); // "Deliver" won't resolve
var result = transportWeb.DeliverAsync(message);
Deliver() was removed in the most recent version of the library. Can you link me to the docs that are out of date?

Resources