|
33 | 33 |
|
34 | 34 | After configuring a `client`, you can do the following things. |
35 | 35 |
|
| 36 | +**response** |
| 37 | + |
| 38 | + - `results`: wrap all data into results |
| 39 | + - `next_link`: get the new link for the next page of data |
| 40 | + |
| 41 | +**to JSON** |
| 42 | + |
| 43 | + - `as_json`: convert office365 object to JSON format |
| 44 | + |
36 | 45 | **Get Profile (as the authenticated user)** |
37 | 46 |
|
38 | 47 | ```ruby |
39 | | -client.me |
| 48 | +irb(main):004:0> response = client.me |
| 49 | +irb(main):010:0> response.display_name |
| 50 | +=> "Hello World" |
| 51 | +irb(main):004:0> response.as_json |
| 52 | +=> { |
| 53 | + :odata_context=>"https://graph.microsoft.com/v1.0/$metadata#users/$entity", |
| 54 | + :display_name=>"Hello World", |
| 55 | + :surname=>"Hello", |
| 56 | + :given_name=>"World", |
| 57 | + :id=>"d7e954e0b50095ad", |
| 58 | + :user_principal_name=>"hello.world@mail.com", |
| 59 | + :business_phones=>[], |
| 60 | + :job_title=>nil, |
| 61 | + :mail=>nil, |
| 62 | + :mobile_phone=>nil, |
| 63 | + :office_location=>nil, |
| 64 | + :preferred_language=>nil |
| 65 | +} |
40 | 66 | ``` |
41 | 67 |
|
42 | | -**Get all calendars** |
| 68 | +**Get my calendars** |
43 | 69 |
|
44 | 70 | ```ruby |
45 | | -client.calendars |
| 71 | +irb(main):005:0> client.calendars |
| 72 | +irb(main):005:0> client.calendars[:results] |
| 73 | +irb(main):005:0> client.calendars[:next_link] |
46 | 74 | ``` |
47 | 75 |
|
48 | | -**Get all mailbox** |
| 76 | +**Get my mails** |
49 | 77 |
|
50 | 78 | ```ruby |
51 | | -client.messages |
52 | | -client.messages({ filter: "createdDateTime lt 2022-01-01" }) |
53 | | -client.messages_with_nextlink |
54 | | -client.messages_with_nextlink(next_link: true, params: { filter: "createdDateTime lt 2022-01-01" }) |
| 79 | +irb(main):005:0> client.messages |
| 80 | +irb(main):005:0> client.messages[:results] |
| 81 | +irb(main):005:0> client.messages({ filter: "createdDateTime lt 2022-01-01" }) |
| 82 | +irb(main):005:0> client.messages({ filter: "createdDateTime lt 2022-01-01", next_link: 'https://....' }) |
55 | 83 | ``` |
56 | 84 |
|
57 | | -**Get all contact** |
| 85 | +**Get my contacts** |
58 | 86 |
|
59 | 87 | ```ruby |
60 | | -client.contacts |
| 88 | +irb(main):018:0> response = client.contacts |
| 89 | +irb(main):020:0> client.contacts[:results][0].display_name |
| 90 | +=> "Encore S." |
| 91 | +irb(main):018:0> response[:results][0].as_json |
| 92 | +=> { |
| 93 | + :odata_etag=>"W/\"EQAAABYAAACbUc86NQthQ7+Mvj19ecwVAABjabQj\"", |
| 94 | + :id=>"AQMkADAwATM3ZmYAZS00ZTU5LWY3NwBjLTAwAi0wMAoARgAAA4QFHqPHk4JJj7ZVaRPCKk4HAJtRzzo1C2FDv4y_PX15zBUAAAIBDgAAAJtRzzo1C2FDv4y_PX15zBUAAABja1I_AAAA", |
| 95 | + :created_date_time=>"2022-10-24T02:48:56Z", |
| 96 | + :last_modified_date_time=>"2022-10-24T02:48:57Z", |
| 97 | + :change_key=>"EQAAABYAAACbUc86NQthQ7+Mvj19ecwVAABjabQj", |
| 98 | + :categories=>[], |
| 99 | + :parent_folder_id=>"AQMkADAwATM3ZmYAZS00ZTU5LWY3NwBjLTAwAi0wMAoALgAAA4QFHqPHk4JJj7ZVaRPCKk4BAJtRzzo1C2FDv4y_PX15zBUAAAIBDgAAAA==", |
| 100 | + :birthday=>nil, |
| 101 | + :file_as=>"", |
| 102 | + :display_name=>"Name S.", |
| 103 | + :given_name=>"Name", |
| 104 | + :initials=>nil, |
| 105 | + :middle_name=>nil, |
| 106 | + :nick_name=>nil, |
| 107 | + :surname=>"S.", |
| 108 | + :title=>nil, |
| 109 | + :yomi_given_name=>nil, |
| 110 | + :yomi_surname=>nil, |
| 111 | + :yomi_company_name=>"", |
| 112 | + :generation=>nil, |
| 113 | + :im_addresses=>[], |
| 114 | + :job_title=>"", |
| 115 | + :company_name=>nil, |
| 116 | + :department=>"", |
| 117 | + :office_location=>"", |
| 118 | + :profession=>nil, |
| 119 | + :business_home_page=>"", |
| 120 | + :assistant_name=>"", |
| 121 | + :manager=>"", |
| 122 | + :home_phones=>[], |
| 123 | + :mobile_phone=>"", |
| 124 | + :business_phones=>[], |
| 125 | + :spouse_name=>"", |
| 126 | + :personal_notes=>"", |
| 127 | + :children=>[], |
| 128 | + :email_addresses=>[{"name"=>"name@google.com", "address"=>"name@google.com"}], |
| 129 | + :home_address=>{}, |
| 130 | + :business_address=>{}, |
| 131 | + :other_address=>{} |
| 132 | +} |
61 | 133 | ``` |
62 | 134 |
|
63 | 135 | ## Copyright |
|
0 commit comments