I can send data and fill simple custom fields. But it does not work with ACF repeater fields. It does not get value at all.
using (var client = new WordPressClient(new WordPressSiteConfig
{
BaseUrl = "http://example.com",
Username = "username",
Password = "pass",
BlogId = 1
}))
{
var customFields = new[]
{
new CustomField
{
Key = "field_586c1a9332541",
Value = "google.com";
}
};
var post = new Post
{
PostType = "video",
Title = "title",
Content = "description",
PublishDateTime = DateTime.Now,
Status = "draft",
CustomFields = customFields
};
var id = client.NewPost(post);
}
Is it possible to work with repeater fields by WordPressSharp ?!
Related
here is the code:-
static I used its worked fine.. how can I store product dynamically in using asp.net c#
LineItems = new List<SessionLineItemOptions>
{
for (int i = 0; i < dtOrder.Rows.Count; i++){
new SessionLineItemOptions
{
Name=dtOrder.Rows[i]["ProductName"].toString(),
Currency="cad",
Amount =Convert.toInt64(dtOrder>Rows[i]["Price"])*100,
Quantity = 1,
},
}
},
Extending the snippet shown in the API reference here, we can replace Price = 'price_123' with PriceData (API ref) like so:
var options = new SessionCreateOptions
{
SuccessUrl = "https://example.com/success",
CancelUrl = "https://example.com/cancel",
PaymentMethodTypes = new List<string>
{
"card",
},
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
Currency = "usd",
UnitAmount = 50000,
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = "some product name",
}
},
Quantity = 2,
},
},
Mode = "payment",
};
var service = new SessionService();
service.Create(options);
You can find all the type definitions in the source code.
I integrated Mulitple Account Payment of stripe and fixed the issue like this
and its working for me now , you can also use simple checkout method like this fetching dynamically product from db
List lineItemsOptions = new List();
string cmdText = "select * from tableorder where sessionid='"+ sessionid + "'";
DataSet ds = dbm.getDs(cmdText);
foreach (DataRow row in ds.Tables[0].Rows)
{
var currentLineItem = new SessionLineItemOptions
{
Name = row["ProductName"].ToString(),
Amount = 100,//Convert.ToInt32( row["variationPrice"].ToString()),
Currency = "usd",
Quantity = Convert.ToInt32(row["Quantity"].ToString()),
};
lineItemsOptions.Add(currentLineItem);
}
StripeConfiguration.ApiKey = ".......................................";
var options = new SessionCreateOptions();
options = new SessionCreateOptions
{
PaymentMethodTypes = new List<string>
{
"card",
},
LineItems = lineItemsOptions,
PaymentIntentData = new SessionPaymentIntentDataOptions
{
ApplicationFeeAmount = 1,
},
Mode = "payment",
SuccessUrl = "https://www.......com/success.aspx",
CancelUrl = "https://example.com/cancel",
};
var requestOptions = new RequestOptions
{
StripeAccount = ".............",
};
var service = new SessionService();
Session session = service.Create(options, requestOptions);
I'm trying this code to create object Event using C#,
three month ago its worked and I created the events but now doesn't work, I realized that assembly has a new parameter "Event Type" but I don't know if It affects my object event
Event calendarEvent = new Event();
DateTime start = DateTime.Now;
calendarEvent.Kind = "";
calendarEvent.Summary = "test";
calendarEvent.Status = "confirmed";
calendarEvent.Visibility = "public";
calendarEvent.Description = "test";
calendarEvent.Creator = new Event.CreatorData
{
Email= "email#example.com",
Self=true
};
calendarEvent.Organizer = new Event.OrganizerData
{
Email = "email#example.com",
Self = true
};
calendarEvent.Start = new EventDateTime
{
DateTime = start,
TimeZone = "America/Mexico_City"
};
calendarEvent.End = new EventDateTime
{
DateTime = start.AddHours(1),
TimeZone = "America/Mexico_City"
};
calendarEvent.Recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=1" };
calendarEvent.Sequence = 0;
calendarEvent.HangoutLink = "";
calendarEvent.ConferenceData = new ConferenceData
{
CreateRequest = new CreateConferenceRequest
{
RequestId = "1234abcdef",
ConferenceSolutionKey = new ConferenceSolutionKey
{
Type = "hangoutsMeet"
},
Status = new ConferenceRequestStatus
{
StatusCode = "success"
}
},
EntryPoints = new List<EntryPoint>
{
new EntryPoint
{
EntryPointType = "video",
Uri = "",
Label = ""
}
},
ConferenceSolution = new ConferenceSolution
{
Key = new ConferenceSolutionKey
{
Type = "hangoutsMeet"
},
Name = "Google Meet",
IconUri = ""
},
ConferenceId = ""
};
//calendarEvent.EventType = "default";
When excute the line to create the event:
EventsResource.InsertRequest request = service.Events.Insert(calendarEvent, "email#example.com");
request.ConferenceDataVersion = 1;
Event createdEvent = request.Execute();
I get:
Google.Apis.Requests.Request Error Invalid conference type value. [400] Reason[invalid] Domain[global]"
When creating an event with a new conference data. You just need to specify the createRequest field, and set the conferenceDataVersion request parameter to 1 for all event modification requests.
Try this:
calendarEvent.ConferenceData = new ConferenceData
{
CreateRequest = new CreateConferenceRequest
{
RequestId = "1234abcdef",
ConferenceSolutionKey = new ConferenceSolutionKey
{
Type = "hangoutsMeet"
}
},
};
I am using Adaptive card combo box to show some categories of products. Once the user clicks on the category that category should pass to another method and display all the products of that category in another adaptive card Combo Box and let user select a product.
Here is the code to get all category to combo box.
public async Task GetCategoryAdaptiveCard(IDialogContext context)
{
var replyToConversation = context.MakeMessage();
replyToConversation.Attachments = new List<Attachment>();
HttpResponseMessage response = new HttpResponseMessage();
string query = string.Format(APIChatBot + "/AllCategory");
using (var client = ClientHelper.GetClient())
{
response = await client.GetAsync(query);
}
var categoryList = await response.Content.ReadAsAsync<IEnumerable<CategoryDTO>>();
AdaptiveCard adaptiveCard = new AdaptiveCard();
adaptiveCard.Speak = "Please Select A Category from the list";
adaptiveCard.Body.Add(new TextBlock()
{
Text = "Please Select A Category from the list",
Size = TextSize.Normal,
Weight = TextWeight.Normal
});
adaptiveCard.Body.Add(new TextBlock()
{
Text = "Category List",
Size = TextSize.Normal,
Weight = TextWeight.Normal
});
List<AdaptiveCards.Choice> list = new List<AdaptiveCards.Choice>();
foreach (var item in categoryList)
{
AdaptiveCards.Choice choice = new AdaptiveCards.Choice()
{
Title = item.CategoryName,
Value = item.Id.ToString()
};
list.Add(choice);
}
adaptiveCard.Body.Add(new ChoiceSet()
{
Id = "Category",
Style = ChoiceInputStyle.Compact,
Choices = list
});
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = adaptiveCard
};
replyToConversation.Attachments.Add(attachment);
await context.PostAsync(replyToConversation);
}
Here is the method i used to get the Product for the selected category.
public async Task GetProductForCategory(IDialogContext context, string category)
{
var replyToConversation = context.MakeMessage();
replyToConversation.Attachments = new List<Attachment>();
HttpResponseMessage response = new HttpResponseMessage();
string query = string.Format(APIChatBot + "/ProductByCategory/" + category);
using (var client = ClientHelper.GetClient())
{
response = await client.GetAsync(query);
}
var productList = await response.Content.ReadAsAsync<IEnumerable<ProductDTO>>();
if(productList .Count() == 0)
{
string message = "Sorry There Are No products For this Category" + category;
await context.PostAsync(message);
}
else
{
List<AdaptiveCards.Choice> list = new List<AdaptiveCards.Choice>();
foreach (var item in productList )
{
AdaptiveCards.Choice choice = new AdaptiveCards.Choice()
{
Title = item.ProductName,
Value = item.Id.ToString()
};
list.Add(choice);
}
AdaptiveCard adaptiveCard = new AdaptiveCard();
adaptiveCard.Body.Add(new TextBlock()
{
Text = "List of Products for the Category " + category,
Size = TextSize.Normal,
Weight = TextWeight.Normal
});
adaptiveCard.Body.Add(new TextBlock()
{
Text = "Please Select A Product From The List",
Size = TextSize.Normal,
Weight = TextWeight.Normal
});
adaptiveCard.Body.Add(new ChoiceSet()
{
Id = "ProductForCategory",
Style = ChoiceInputStyle.Compact,
Choices = list
});
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = adaptiveCard
};
replyToConversation.Attachments.Add(attachment);
await context.PostAsync(replyToConversation);
}
}
How can i pass the category selected by the user to the method that selects the product based on category?
If you create an adaptive card something like this:
var reply = context.MakeMessage();
var card = new AdaptiveCard();
var choices = new List<Choice>();
choices.Add(new Choice()
{
Title = "Category 1",
Value = "c1"
});
choices.Add(new Choice()
{
Title = "Category 2",
Value = "c2"
});
var choiceSet = new ChoiceSet()
{
IsMultiSelect = false,
Choices = choices,
Style = ChoiceInputStyle.Compact,
Id = "Category"
};
card.Body.Add(choiceSet);
card.Actions.Add(new SubmitAction() { Title = "Select Category", Data = Newtonsoft.Json.Linq.JObject.FromObject(new { button = "select" }) });
reply.Attachments.Add(new Attachment()
{
Content = card,
ContentType = AdaptiveCard.ContentType,
Name = $"Card"
});
await context.PostAsync(reply);
When the user selects one of the options, and clicks the button, the resulting activity's value will be a jobject you can deserialize and use to create a product specific adaptive card:
class CategorySelection
{
public string Category { get; set; }
}
var activityValue = activity.Value as Newtonsoft.Json.Linq.JObject;
if (activityValue != null)
{
var categorySelection = activityValue.ToObject<CategorySelection>();
var category = categorySelection.Category;
//query the database for products of this category type,
//create another adaptive card displaying the products and send to user
await context.PostAsync(reply);
}
How do I add thumbnail image content using joeblogs or xmlrpc?
add content code:
var post = new Post();
post.DateCreated = DateTime.Today.AddHours(0);
post.Title = textBox1.Text;
post.Body = richTextBox1.Text;
post.Categories = new string[] { secilikat };
var cfs = new CustomField[]
{
new CustomField()
{
// Don't pass in ID. It's auto assigned for new custom fields.
// ID = "name",
Key = "post_thumbnail",
Value = linkToImage
}
};
post.CustomFields = cfs;
I have read all the documentation on 3.0 API. Please don't send me there again. I can create a template on DocuSign with Custom Fields and send it out in an envelope but cannot seem to fill in custom fields (tabs?) with values from my application. Can anyone tell me the exact approach? IE: I have tried authenticate-->CreateEnvelopeFromTemplates-->SendEnvelope and just get empty form fields. I tried authenticate-->CreateEnvelope->SendEnvelope ....empty fields. I won't be able to host the file on the local file system anyway, so I think that would be a dead end even if it did work (CRM Online).
here's kind of what the template is like:
!https://dl.dropboxusercontent.com/u/24627933/DocuSign.PNG
here's what I thought was the most promising example:
string auth = "<DocuSignCredentials><Username>" + _userName
+ "</Username><Password>" + _password
+ "</Password><IntegratorKey>" + _IntegratorKey
+ "</IntegratorKey></DocuSignCredentials>";
APIServiceSoapClient _apiClient = new APIServiceSoapClient("APIServiceSoap", _apiUrl);
/* tried this too
Tab RoutingNumber = new Tab()
{
Name = "RoutingNumber",
Type = TabTypeCode.Custom,
Bold = true,
Value = "1234 555 765"
};
Tab PayeeName = new Tab()
{
Name = "PayeeName",
Value = "PaiYee Na Me",
Bold = false,
Type = TabTypeCode.Custom
};
*/
// Construct all the recipient information
Recipient[] recipients = CreateOneSigner();
TemplateReferenceRoleAssignment[] finalRoleAssignments = new TemplateReferenceRoleAssignment[1];
finalRoleAssignments[0] = new TemplateReferenceRoleAssignment();
finalRoleAssignments[0].RoleName = recipients[0].RoleName;
finalRoleAssignments[0].RecipientID = recipients[0].ID;
// Use a server-side template -- you could make more than one of these
TemplateReference templateReference = new TemplateReference();
templateReference.TemplateLocation = TemplateLocationCode.Server;
templateReference.Template = "B3DAD8FD-1B48-4C62-9DB6-A48E5C5B40DC";
//templateReference.Template = "ABE98BE7-A400-493B-A3A3-BA489CEEA166";
templateReference.RoleAssignments = finalRoleAssignments;
templateReference.AdditionalTabs = new Tab[] { RoutingNumber, PayeeName };
// Construct the envelope information
EnvelopeInformation envelopeInfo = new EnvelopeInformation();
envelopeInfo.AccountId = _accountId;
envelopeInfo.Subject = "Irrevocable Commission Test";
envelopeInfo.EmailBlurb = "This is the Irrevocable Commission Disbursement Authorization form related to your Advance Pay request.";
CustomField Company = new CustomField()
{
Name = "Company",
Value = "Some company.",
CustomFieldTypeSpecified = true,
CustomFieldType = CustomFieldType.Text,
Show = "Yes",
Required = "Yes"
};
CustomField PayeeName = new CustomField()
{
Name = "PayeeName",
Value = "some name",
CustomFieldTypeSpecified = true,
CustomFieldType = CustomFieldType.Text,
Show = "Yes",
Required = "Yes"
};
CustomField RoutingNumber = new CustomField()
{
Name = "RoutingNumber",
Value = "my routing num",
CustomFieldTypeSpecified = true,
CustomFieldType = CustomFieldType.Text,
Show = "Yes",
Required = "Yes"
};
CustomField SendToName = new CustomField()
{
Name = "SendToName",
Value = "Residential Advance",
CustomFieldTypeSpecified = true,
CustomFieldType = CustomFieldType.Text,
Show = "Yes",
Required = "Yes"
};
CustomField AccountNumber = new CustomField()
{
Name = "AccountNumber",
Value = "my account ",
CustomFieldTypeSpecified = true,
CustomFieldType = CustomFieldType.Text,
Show = "Yes",
Required = "Yes"
};
CustomField AgentName = new CustomField()
{
Name = "AccountNumber",
Value = "my agent ",
CustomFieldTypeSpecified = true,
CustomFieldType = CustomFieldType.Text,
Show = "Yes",
Required = "Yes"
};
envelopeInfo.CustomFields = new CustomField[] {
Company, PayeeName, RoutingNumber, AccountNumber, SendToName
};
recipients[0].CustomFields = new CustomField[] {
Company, PayeeName, RoutingNumber, AccountNumber, SendToName
};
using (var scope = new System.ServiceModel.OperationContextScope(_apiClient.InnerChannel))
{
var httpRequestProperty = new System.ServiceModel.Channels.HttpRequestMessageProperty();
httpRequestProperty.Headers.Add("X-DocuSign-Authentication", auth);
System.ServiceModel.OperationContext.Current.OutgoingMessageProperties[System.ServiceModel.Channels.HttpRequestMessageProperty.Name] =
httpRequestProperty;
EnvelopeStatus status1 =
_apiClient.CreateEnvelopeFromTemplates(new TemplateReference[] { templateReference },
recipients,
envelopeInfo,
false);
Console.WriteLine(status1);
if (status1.Status.ToString() == "Created")
{
EnvelopeStatus sendStatus = _apiClient.SendEnvelope(status1.EnvelopeID, _accountId);
}
}
I believe you need to use the tabLabel property in order to populate the data field. Try using something like this:
CustomField AccountNumber = new CustomField()
{
TabLabel = "AccountNumber",
Name = "AccountNumber",
Value = "my account ",
CustomFieldTypeSpecified = true,
CustomFieldType = CustomFieldType.Text,
Show = "Yes",
Required = "Yes"
};
It appears that the objects used in the C# examples and suggested above are not correct. The values now show up when I use TemplateReferenceFieldDataDataValue and add that as FieldData.DataValues.
templateReference.RoleAssignments = finalRoleAssignments;
var dataFieldValues = new TemplateReferenceFieldDataDataValue[3];
dataFieldValues[0] = new TemplateReferenceFieldDataDataValue();
dataFieldValues[0].TabLabel = "RoutingNumber";
dataFieldValues[0].Value = "R12345678";
dataFieldValues[1] = new TemplateReferenceFieldDataDataValue();
dataFieldValues[1].TabLabel = "AccountNumber";
dataFieldValues[1].Value = "A87654321";
dataFieldValues[2] = new TemplateReferenceFieldDataDataValue();
dataFieldValues[2].TabLabel = "Escrow";
dataFieldValues[2].Value = "E777333";
templateReference.FieldData = new TemplateReferenceFieldData();
templateReference.FieldData.DataValues = dataFieldValues;
Hope that saves someone else some time.