cakejelly / layer-api Goto Github PK
View Code? Open in Web Editor NEWA ruby toolkit for Layer's Web API's (https://developer.layer.com/docs)
A ruby toolkit for Layer's Web API's (https://developer.layer.com/docs)
This gem is incompatible with other gems which require higher version of faraday.
Request you to please update the dependencies to its latest versions.
thanks.
Tested the same App Id on layer-ruby gem and it works but somehow it doesn't work with this gem.
Layer::Error: Layer responded with status 403: {"id":"invalid_app_id","code":2,"message":"The referenced App ID is invalid.
Hi,
I am using the layer-api gem to load / create conversations on layer. I was trying to update the users identity using the indications from the readme, but as soon as I tried to call the create_identity method on a retrieved user, I received an error saying:
NoMethodError: undefined method `create_identity' for #<Layer::Resources::User:0xcd73618>
Any ideea why is that happening?
I was testing it very simple:
identity = {
display_name: "Frodo the Dodo",
avatar_url: "http://sillylordoftheringspictures.com/frodo-riding-a-dodo.png",
first_name: "Frodo",
last_name: "Baggins",
phone_number: "13791379137",
email_address: "[email protected]",
metadata: {
level: "35",
race: "Dodo"
}
}
user = @platform.users.find("user_id")
user.create_identity(identity)
The gem version I am using is 0.6.1
bundle show | grep layer
* layer-api (0.6.1)
Here is my code:
def update_layer_identity(user)
operations = [
{operation: "set", property: "display_name", value: "Hello Friend"}
]
layer_user = layer_client.users.find(user.uuid)
layer_user.update(operations)
end
And I get the following error:
Layer responded with status 422: {"url":"https://developer.layer.com/docs/platform","data":{"property":"display_name"},"code":9,"id":"invalid_operation","message":"Patch operation \"set\" on \"display_name\" is not allowed."}
Same thing happens when I try to update first_name, last_name and phone_number. I'm able to PATCH successfully using curl, so it must be an issue with this Library?
You should be able to sort the conversations, as such:
conversations = user.conversations.list(sort_by: 'last_message')
However, because of the way the list method was written, that doesn't work. Instead of adding the params to the query parameters, it sends a JSON encoded string as the body of the request, which doesn't make sense for a GET request.
Hi,
when calling the function to_s on a identity_token I get TypeError: no implicit conversion of nil into String, because there are no substitutions when key.gsub!("\n","\n") is called and a nil is returned instead.
Any special reason why you dont use just gsub ?
best regards,
Marko
Hi,
another question. I was looking over the layer documentation and I cant find a way to get a list of conversations for a user and inside the conversation also the last message (with a single call).
Right now I am calling the message list for each conversation and it will be become slow in the future with a lot of conversations.
thx
There's a problem with the way you're handling the 'If-None-Match' header. The token is created when you instantiate the platform object. So if you use that instance to say create two messages, layer will reject the second one:
conv = platform.conversations.find("conversation_id")
conv.messages.create(message)
conv.messages.create(another_message)
another_message
will get rejected and the message won't be send since the API already saw that token and will interpret it as a duplicate.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.