1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
/* 
  Author: Pontus Östlund <https://profiles.google.com/poppanator> 
 
  Permission to copy, modify, and distribute this source for any legal 
  purpose granted as long as my name is still attached to it. More 
  specifically, the GPL, LGPL and MPL licenses apply to this software. 
*/ 
 
//! Instantiates the default Google+ API. 
//! See @[WebApi.Api()] for further information about the arguments 
//! 
//! @param client_id 
//!  Your application key/id 
//! @param client_secret 
//!  Your application secret 
//! @param redirect_uri 
//!  The redirect URI after an authentication 
//! @param scope 
//!  The application scopes to grant access to 
this_program `()(string client_id, string client_secret, 
                 void|string redirect_uri, 
                 void|string|array(string)|multiset(string) scope) 
{ 
  return V1(client_id, client_secret, redirect_uri, scope); 
} 
 
class V1 
{ 
  inherit WebApi.Google.Api; 
 
  //! API base URI. 
  protected constant API_URI = "https://www.googleapis.com/plus/v1"; 
 
  protected constant AuthClass = Auth.Google.Plus; 
 
 
  //! Getter for the @[People] object which has methods for all @expr{people@} 
  //! related Google+ API methods. 
  //! 
  //! @seealso 
  //!  @url{https://developers.google.com/+/api/latest/people@} 
  People `people() 
  { 
    return _people || (_people = People()); 
  } 
 
  //! Getter for the @[Activities] object which has methods for all 
  //! @expr{activities@} related Google+ API methods. 
  //! 
  //! @seealso 
  //!  @url{https://developers.google.com/+/api/latest/activities@} 
  Activities `activities() 
  { 
    return _activities || (_activities = Activities()); 
  } 
 
  //! Class implementing the Google+ People API. 
  //! @url{https://developers.google.com/+/api/latest/people@} 
  //! 
  //! Retreive an instance of this class through the 
  //! @[Social.Google.Plus()->people] property 
  class People 
  { 
    inherit Method; 
    protected constant METHOD_PATH = "/people/"; 
 
    //! Get info ablut a person. 
    //! 
    //! @param user_id 
    //!  If empty the currently authenticated user will be fetched. 
    //! @param cb 
    //!  Callback for async request 
    mapping get(void|string user_id, void|Callback cb) 
    { 
      return _get(user_id||"me", 0, cb); 
    } 
 
    //! List all of the people in the specified @[collection]. 
    //! 
    //! @param user_id 
    //!  If empty the currently authenticated user will be used. 
    //! 
    //! @param collection 
    //!  If empty "public" activities will be listed. Acceptable values are: 
    //!  @ul 
    //!   @item "public" 
    //!    The list of people who this user has added to one or more circles, 
    //!    limited to the circles visible to the requesting application. 
    //!  @endul 
    //! 
    //! @param params 
    //!  @mapping 
    //!   @member int "maxResult" 
    //!    Max number of items ti list 
    //!   @member string "orderBy" 
    //!    The order to return people in. Acceptable values are: 
    //!    @ul 
    //!     @item "alphabetical" 
    //!      Order the people by their display name. 
    //!     @item "best" 
    //!      Order people based on the relevence to the viewer. 
    //!    @endul 
    //!   @member string "pageToken" 
    //!    The continuation token, which is used to page through large result 
    //!    sets. To get the next page of results, set this parameter to the value 
    //!    of @expr{nextPageToken@} from the previous response. 
    //!  @endmapping 
    //! 
    //! @param cb 
    //!  Callback for async request 
    mapping list(void|string user_id, void|string collection, 
                 void|ParamsArg params, void|Callback cb) 
    { 
      return _get((user_id||"me") + "/activities/" + (collection||"public"), 
                  params, cb); 
    } 
  } 
 
  //! Class implementing the Google+ Activities API. 
  //! @url{https://developers.google.com/+/api/latest/activities@} 
  //! 
  //! Retreive an instance of this class through the 
  //! @[activities] property 
  class Activities 
  { 
    inherit Method; 
    protected constant METHOD_PATH = "/activities/"; 
 
    mapping activity(string activity_id, void|Callback cb) 
    { 
      return _get(activity_id, 0, cb); 
    } 
  } 
 
  //! Internal singleton objects. Get an instance via @[people] and 
  //! @[activities]. 
  private People _people; 
  private Activities _activities; 
}