On my application, I would like to add a post and user in tandem using jsonapi:resources. A user can be created already. And a post can be created already if someone is signed in. However for this special scenario I would like a user to be able to submit their first post while creating their account. Here is the payload that would be submitted.
{
"data":{
"user":{
"attributes":{
"name": "blah blah",
"age": 20,
"address": "mickey mouse street"
}
},
"relationships": {
"post": {
"content": "this is a new post",
"type": "blog"
}
}
}
}
Is this at all possible? If so in which resource file would I create them both? Would it be the resource file for posts or for users? Or would it be best practice to create the user first and then once the user has been created make a separate call to create the post? Thanks!
Related
I'm trying to implement Document signing on my rails app.
I have a template which is sent to many users.
So i have made a custom tag with label Member and i want to fill it with a custom text say 'abc' through my app.
Here is my code which i tried so far. The member part still looks blank. Other fields like name, signature and date are working properly.
client = DocusignRest::Client.new
#envelope_response = client.create_envelope_from_template(
status: 'sent',
email: {
subject: "The test email subject envelope 7",
body: "Envelope body content here"
},
template_id: template_id,
signers: [
{
name: 'Name',
email: 'sample_email#gmail.com',
role_name: 'Expert',
tabs: {
text_tabs: [
{
tab_label: 'Member',
value: 'abc'
}
]
}
}
]
)
I dont know where i went wrong. Please help
it seems the 'text_tabs' should not be embedded inside a 'tabs'. instead, pass the 'text_tabs' directly within a signer. also, instead of 'tab_label', try just using 'label'.
This seems like it should be pretty simple but I can't seem to figure this out (bit new to Ember). I have a json file that I am using to load data into an ember template with handlebars. I am trying to have it so by visiting /site/id/ it would load data based on the id in the json file. Right now, it loads my json but only takes data from the first json entry. So no matter what /site/anythinghere/, that data is loaded. I am trying to make it dynamic.
I think my problem has to do with not having a model setup properly in ember. I've seen the docs and tutorials talk about the model: property and passing (params) and what not, but I can't seem to get anything to work in my site model or route.
Here's my code...
Router.js.coffee:
App.Router.map ->
#resource 'site', ->
#route 'show', path: '/:site_id'
Routes.rb:
#routes.rb
Rails.application.routes.draw do
root to: 'home#index'
scope constraints: { format: :html } do
get '/site' => 'home#index'
get '/site/:site_id' => 'home#index'
resources 'sites'
end
end
sites_controller.rb:
class SitesController < ApplicationController
def show
render json: File.open('data/sites.json').read
end
end
models/site.js.coffee:
App.Site = DS.Model.extend()
data/sites.json
{
"site": [
{
"id": "1",
"name": "Place One",
"type": "Type One"
}, {
"id": "2",
"name": "Place One",
"type": "Type Two"
}
]
}
I'm working in Koala with Facebook's Graph API 2.0. Now when you call user_friends using
<% #friends = #graph.get_connections("me", "friends") %>
You should get an object that contains something like the following:
{
"data": [
{
"name": "Friend 1",
"id": "xxxxx"
},
{
"name": "Friend 2",
"id": "xxxx"
},
],
"paging": {
"next": "https://graph.facebook.com/v2.1/...."
},
"summary": {
"total_count": number of friends
}
}
My question is how do I pull the information from summary. I tried printing this in my ruby app but I only saw the following:
[]
Does that mean the return was nil? I tried to call #friends.summary, but that didn't work
Thoughts?
https://developers.facebook.com/docs/apps/changelog
The list of friends returned via the /me/friends endpoint is now limited to the list of friends that have authorized your app.
Also make sure you authorized yourself with the user_friends permission, of course.
I am trying to test the docusign_rest gem for possible integration into my rails app. I have set up the gem and configured it with my username, password, and integrator key. I have set the version of the api to 'v2' and checked all the of the names of both the signers and the tab fields multiple times. Here is the code I am using to make the request:
response = c.create_envelope_from_template(
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
signers: [
{
embedded: false,
name: "Name",
email: 'example#gmail.com',
role_name: "Signer1",
tabs: {
textTabs: [
{
tabLabel: "\\*address",
value: "123 Example St.",
locked: true
}
]
}
}
]
)
The request gets sent and the envelope gets sent but the 'address' field is not populated. Is there anything I am doing obviously wrong?
Thanks in advance.
Try changing the signers node in you request body to templateRoles. When you use templates in DocuSign instead of specifying the signers and their types and tabs, you assign them to existing template roles that are configured in the template. That's why no signer types should be specified in this call, just the template roles that each recipient will get matched to, and the values of any tabs you want to populate.
I've never used Ruby before so there might be some formatting or syntax issues I'm missing here, and I also have never seen the ruby gem you're referring to so not sure how stable or correct that code is. But basically this is what I think you need to do...
Right now you have:
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
signers: [
{
...
Try changing signers to templateRoles, like so:
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
templateRoles: [
{
...
The resulting http request body that you need to construct should look something like the following (in JSON format):
{
"emailSubject": "DocuSign API - Signature Request from Template",
"templateId": "ABCD1234",
"templateRoles": [
{
"email": "firstperson#email.com",
"name": "John Doe",
"roleName": "Template Role Name goes here",
"tabs": [
{
"textTabs": [
{
"tabLabel": "\\*address",
"value": "432 Sorrento Dr.",
"locked": "true"
}
]
}
]
}
],
"status": "sent"
}
Lastly, the DocuSign API Walkthrough for requesting a signature from a template is a great resource for sending from a template so this might help too. There's sample code for making this api call in 6 different languages (unfortunately Ruby is not one of them):
http://iodocs.docusign.com/APIWalkthrough/requestSignatureFromTemplate
Finally figured it out myself by modifying the gem to inspect the request. With the docusign_rest gem, the documentation on the github page is incorrect. The tabs dictionary should not be there and the items in this specific request should be underscore separated instead of camel case. Therefore, the actual request would look something like:
response = c.create_envelope_from_template(
status: 'sent',
email: {
subject: 'Test email subject',
body: 'Test email body',
},
template_id: template["templateId"],
signers: [
{
embedded: false,
name: 'Name',
email: 'example#gmail.com',
role_name: 'Signer1',
text_tabs: [
{
label: 'Address',
name: 'Address',
value: '123 Example Street.',
}
]
}
]
)
This request will allow you with the gem and v2 of the api to create an envelope from a template and prepopulate any fields. All other field types go the same way as the text_tabs array.
I'm doing it on ios. When I get a user's info(gendar,locale,etc), such as Bill Gates(216311481960), it will return error. Maybe because these info are not public. If I just get name,link, picture, that will be OK. But how can I handle this kind of error. How can I know which info can be retrieved?
Thanks.
Without a user access token, pubic info can be grabbed this way: http://graph.facebook.com/216311481960
{
"id": "216311481960",
"name": "Bill Gates",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/276582_216311481960_498814368_s.jpg",
"link": "http://www.facebook.com/BillGates",
"likes": 1216122,
"category": "Public figure",
"is_published": true,
"website": "www.thegatesnotes.com www.gatesfoundation.org",
"username": "BillGates",
"talking_about_count": 25035
}
As you can see this doesn't appear to be user information, but rather page information.
For user information, you need to use a Facebook user id. Zuck's is 4...so do: http://graph.facebook.com/4
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Notice how it has both first_name and last_name, while the "Bill Gates" one you have as an example is clearly not a "user" but a page.
With a valid user access token, all shared information can be grabbed this way:
http://graph.facebook.com/me?access_token=ValidUserAccessToken