Google api ruby client issue with the insert_calendar method - ruby

I am using the google code sample for the google calendar api. This code is supposed to make a new calendar using the google calendar api. I am not clear on how to get access to the insert_calendar method.
Does anybody know where did the client object come from in the results variable? What class does it come from?
calendar = Google::Apis::CalendarV3::Calendar.new(
summary: 'calendarSummary',
time_zone: 'America/Los_Angeles'
)
result = client.insert_calendar(calendar)
print result.id
I don't know how to make a new one of those. When I make a new object like:
client = Google::APIClient.new
and I call methods, on it. I do not find an insert_calendar method. Can some one tell me what object I would need to instantiate in order to have the insert_calendar method?
This is a simple question but I am having a huge problem finding out how to answer this on my own.

The docs page is here. It looks like it's an instance method of Google::Apis::CalendarV3::CalendarService.
Since the usage isn't particularly clear from this documentation, I went to the google-api-client source on Github and used the "search this repository" tool to find where insert_calendar is defined.
It's in this file.
From looking at the source & docs I can advise you try the following code (though I haven't verified this:
calendar = Google::Apis::CalendarV3::Calendar.new(
summary: 'calendarSummary',
time_zone: 'America/Los_Angeles'
)
Google::Apis::CalendarV3::CalendarService.new.insert_calendar(
calendar: calendar,
# other options can go here
)

Related

Eventbrite APi : Get ticket /price information for events

Im using Eventbrites api to get information about events. I cant find any price information on the event, even though I can see price information if I check the events page at eventbrite site.
I can see from here that there is an optional property "ticket_availability", but its seems to be non-existing, even though I can see price info on the eventĀ“s eventbrite page)
Further down in the documentation its also mention something called "Ticket class", that should be an anonymous object, but I cant find it anywhere,
(and yes, I have contacted their dev support)
[Accepted answer, cant set it until tomorrow]
Answer from eventbrite:s dev support. If you see this: THANKS!(again) :D
Ticket Classes are the object that we use to represent the prices of an event.
I think this is the endpoint you're looking for:
GET /v3/event/[EVENT ID]/ticket_classes/
https://www.eventbrite.com/developer/v3/endpoints/events/#ebapi-get-events-id-ticket-classes
That will return a list of Ticket Class objects (since events can have more than one price). Here's the documentation on the Ticket Class object it self. The cost field is what you are likely interested in.
I ran into this issue and it turns out ticket_availability is an expansion field for the event endpoints, so you have to request it specifically.
For example, this request:
https://www.eventbriteapi.com/v3/venues/28582043/events/
Would need to become:
https://www.eventbriteapi.com/v3/venues/28582043/events/?expand=ticket_availability
This section of the documentation explains expansions: https://www.eventbrite.com/platform/api#/introduction/expansions
At the top of the documentation for Events you can see the list of expansions that are available for event endpoints: https://www.eventbrite.com/platform/api#/reference/event
ticket_availability doesn't contain the full data on the tickets, so using Ticket Classes as the other answer mentions is the way to go if you need a lot of information about tickets for a particular event. For example:
https://www.eventbriteapi.com/v3/events/216395423537/ticket_classes/for_sale/

Cant get facebook date range working for events in ruby/koala

I am using ruby koala facebook graph API gem to retrieve events but cant restrict the events using a date range. I seem to be getting all events (even ones which have happened). What I am trying to do is get events is the next 200 days. I am using the following (ruby) code:
Koala.config.api_version = 'v2.10'
oauth = Koala::Facebook::OAuth.new app_id, app_secret
graph = Koala::Facebook::API.new oauth.get_app_access_token
from_date = Date.today
to_date = from_date + 200
fb_events = graph.get_object( fb_venue["url_listings"] + "?time_range={\"since\":#{from_date}, \"until\":#{to_date}" )
I am then getting the events 25 at once (the facebook default limit) using 'fb_events.next_page' to get them all.
I seem to get getting all events, including ones is the past.
Are you sure that the #get_object method wants a query string like that? Based on the docs[1], it seems that you should pass your object ID (which I assume is in fb_venue['url_listings'] for you as a first arg, and then metadata in a subsequent arg as a Hash. So I'd try something like:
fb_events = graph.get_object(fb_venue['url_listings'],
{since: from_date, until: to_date})
...according to the key/nesting structure FB expects.
Edit: forgot link to docs.
[1] -
http://www.rubydoc.info/github/arsduo/koala/Koala%2FFacebook%2FGraphAPIMethods%3Aget_object
According to the doc I don't think that you can request all the events, You can only select an event by using /{event-id} like this example or you can get user's events but you will need to ask him for the permission according to
permissions.
add user_events to the list of scope that you are permitting from user.
By this when user sign up using Facebook to your application it will take a permission for his events.
After that by using graph.get_object({facebook-user-id} + '/events') you will get 25 of his events as a default value and you can add {limit: 5} as a second parameter to the get_object function, You can use until and since but they should be in A Unix timestamp look at this to see the needed date format, hope this would help.

How to create/add a summary band with DynamicJasper?

I couldn't find anything in the official Doc & Exam.
Seems there is not a single "intuitive" method or object in the whole API to achieve this

Ruby viewpoint with EWS

I am trying to get started using viewpoint against EWS within Ruby, and it's not making a lot of sense at the moment. I am wondering where I can get some good example code, or some pointers? I am using 1.0.0-beta.
For example: I know the name of the calendar folder I want to use, so I could search for it, but how to access methods in that folder once I find it? What are the appropriate parameters, etc...
Any advice?
If you haven't read it yet I would recommend the README file in the repository. It has a couple of examples that should put you on the right path. Also, the generated API documentation should give you enough to work with.
http://rubydoc.info/github/WinRb/Viewpoint/frames
At a very basic level you can get all of your calendar events with the following code:
calendar = client.get_folder :calendar
events = calendar.items
I hope that gives you a little more to get started with.
Follow-up:
Again, I would point you to the API docs for concrete methods like #items. There are however dynamically added methods depending on the type that you can fetch with obj.ews_methods. In the case of CalendarItem one of those methods is #name so you can call obj.name to get the folder name. The dynamic methods are all backed by a formatted Hash based on the returned SOAP packet. You can see it in its raw format by issuing obj.ews_item
Cheers,
Dan

framework and aprroach to get youtube insight data using ruby

I need to get user, channel & video insight data (views, ratings, subscribers etc) from youtube using ruby.
which tool/gem/framework to use:
I know this is asked before, but this is specific to my problem, I dont want to upload videos etc, most of the frameworks seem geared to this.
None of these seem to be a great fit to me, am I better off using httparty and rolling my own?
youtube-model - http://github.com/edgarjs/youtube-model/tree/master
youtube-g - http://github.com/tmm1/youtube-g
gdata on rails - http://code.google.com/apis/gdata/articles/gdata_on_rails.html
which api to use?
Should I use this api: http://code.google.com/apis/youtube/2.0/developers_guide_protocol_insight.html
I need a list of videos before I can call this, also I need to figure out what channel the user has, ideally get insight data at the channel level, if not I can aggregate it.
Or are feeds: http://code.google.com/apis/youtube/2.0/developers_guide_protocol_understanding_video_feeds.html
a better way to get this kind of data.
I spent some time working on this over the weekend. Youtube-Model seems to work the best:
Use example in youtube model to get authsub token
yt = YouTubeAccess.uploaded_by_user(token)
yt_videos = yt.videos
yt_videos.each{|video|
view_count = video.statistics.viewCount.to_i
favorite_count = video.statistics.favoriteCount.to_i
comment_count = video.comments.attributes['feedLink'].countHint.to_i
}
Not sure how to do channels, but this is a good start.

Resources