github.com/grokify/go-ringcentral-client@v0.3.31/codegen/specs-engagedigital_v3.0.0/conv_doc2schema.rb (about) 1 #!ruby 2 3 require 'multi_json' 4 5 doc = ' 6 { 7 "id":"5cde163bd6cb00d3034e2332", 8 "created_at":"2019-05-17T02:02:35Z", 9 "updated_at":"2019-05-17T02:31:03Z", 10 "category_ids":[ 11 12 ], 13 "email":"embbnux.ji@ringcentral.com", 14 "enabled":true, 15 "external_id":null, 16 "firstname":"Nux", 17 "gender":null, 18 "identity_ids":[ 19 20 ], 21 "lastname":"Ji", 22 "locale":"en", 23 "nickname":null, 24 "rc_user_id":null, 25 "role_id":"5c8bf22b14bf8a84c44c7750", 26 "spoken_languages":[ 27 "en" 28 ], 29 "team_ids":[ 30 31 ], 32 "timezone":"", 33 "invitation_pending":false 34 } 35 ' 36 doc = ' 37 { 38 "id":"5c8bf22b14bf8a84c44c7753", 39 "created_at":"2019-03-15T18:42:51Z", 40 "updated_at":"2019-03-15T18:42:51Z", 41 "label":"Agent", 42 "approve_content":false, 43 "assign_intervention":false, 44 "author_block_content":false, 45 "admin_stamp_answer":true, 46 "close_content_thread":true, 47 "mute_content":false, 48 "update_own_intervention":true, 49 "update_intervention":false, 50 "publish_content":true, 51 "delay_export_content":true, 52 "receive_tasks":true, 53 "search_contents":true, 54 "open_content_thread":true, 55 "impersonate_user":false, 56 "delete_content_thread":false, 57 "use_emoji":true, 58 "access_pull_mode":true, 59 "read_event":true, 60 "read_presence":true, 61 "read_identity":true, 62 "access_previous_messages":true, 63 "use_cobrowsing":true, 64 "invite_user":false, 65 "create_user":false, 66 "read_user":true, 67 "update_user":false, 68 "manage_users_of_my_teams":false, 69 "manage_identities":false, 70 "update_identity":true, 71 "manage_teams":false, 72 "manage_roles":false, 73 "manage_own_notifications":false, 74 "manage_categories":false, 75 "manage_folders":false, 76 "manage_custom_notifications":false, 77 "read_community":false, 78 "create_community":false, 79 "update_community":false, 80 "read_content_source":false, 81 "create_content_source":false, 82 "update_content_source":false, 83 "manage_chat":false, 84 "manage_messaging":false, 85 "manage_topologies":false, 86 "read_export":false, 87 "search_event":false, 88 "update_settings":false, 89 "manage_tags":false, 90 "manage_custom_fields":false, 91 "manage_emails_templates":false, 92 "manage_api_access_tokens":false, 93 "create_and_destroy_extension":false, 94 "update_extension":false, 95 "update_time_sheet":false, 96 "manage_app_sdk_applications":false, 97 "access_help_center":true, 98 "manage_ice":false, 99 "export_identity":false, 100 "anonymize_identity":false, 101 "lock_identity":false, 102 "read_stats":false, 103 "read_own_stats":true, 104 "monitor_tasks":false, 105 "monitor_team_tasks":false, 106 "manage_reply_assistant":false, 107 "reply_with_assistant":true, 108 "manage_rules_engine_rules":false 109 } 110 ' 111 112 doc = ' 113 { "id": "5b87a6b2f042de5f94fabf8d", 114 115 "created_at": "2018-08-30T08:11:30Z", 116 "updated_at": "2018-08-30T08:11:30Z", 117 "content_type": "image/jpeg", 118 "filename": "cat.jpeg", 119 "foreign_id": null, 120 121 122 "size": 700754, 123 "url": "http://domain-test.engagement.dimelo.dev/attachments/5b87a6b2f042de5f94fabf8d", 124 125 126 "video_metadata": [], 127 "embed": false, 128 "public?": true 129 130 } 131 ' 132 doc = ' 133 { 134 "id": "60944e5702bdafb74ec96142", 135 "parent_id": "eb3c62690ec9025845fd3495", 136 "name": "Technical", 137 "created_at": "2012-05-23T01:12:49Z", 138 "updated_at": "2012-05-23T01:12:49Z", 139 "color": 0, 140 "mandatory": false, 141 "multiple": true, 142 "post_qualification": false, 143 "source_ids": [], 144 "unselectable": false }' 145 146 doc = '{ 147 "id":"5c8bf22b14bf8a84c44c773b", 148 "created_at":"2019-03-15T18:42:51Z", 149 "updated_at":"2019-07-24T09:26:42Z", 150 "activity_presence_threshold":45, 151 "activity_tracking":true, 152 "beginning_of_week":"monday", 153 "content_languages":[ 154 "en" 155 ], 156 "deny_iframe_integration":false, 157 "disable_password_autocomplete":false, 158 "dump_in_preprod":false, 159 "expire_password_after":7776000, 160 "expire_password_enabled":false, 161 "fte_duration":7, 162 "identity_merge":true, 163 "intervention_defer_rates":[ 164 1800, 165 86400, 166 259200 167 ], 168 "intervention_defer_threshold":86400, 169 "intervention_rates":[ 170 3600, 171 10800, 172 86400, 173 259200 174 ], 175 "locale":"en", 176 "multi_lang":false, 177 "name":"rc-platform", 178 "password_archivable_enabled":false, 179 "password_archivable_size":5, 180 "password_min_length":6, 181 "password_non_word":false, 182 "password_numbers":false, 183 "password_recovery_disabled":false, 184 "push_enabled":true, 185 "reply_as_any_identity":false, 186 "rtl_support":false, 187 "self_approval_required":false, 188 "session_timeout":240, 189 "sharding_key":"rc_platform", 190 "spellchecking":false, 191 "style":"ringcentral", 192 "third_party_services_disabled":false, 193 "timezone":"Pacific Time (US & Canada)", 194 "type":"demo", 195 "urgent_task_threshold":60, 196 "browser_notifications_disabled":false, 197 "display_only_unknown_bbcode":false, 198 "intervention_closing_period":432000, 199 "use_two_letters_avatars":true 200 }' 201 202 doc = '{"id": "73f1cb2938229d7fa222d096", 203 "source_id": "d19c81948c137d86dac77216", 204 "source_url": "http://domain-test.answers.dimelo.com/questions/42", 205 "source_type": "answers", 206 "thread_id": "26c56bc5b71c5193b6f8c656", 207 "in_reply_to_id": "58bc74bc920026b30196fdf4", 208 "in_reply_to_author_id": "57ea9a7f13047d506e65289d", 209 "author_id": "4f0aa52d656a3d75867f784c", 210 "creator_id": "ac24dc966bc7ecb74017c0cd", 211 "foreign_id": "7789", 212 "type": "question", 213 "created_from": "synchronizer", 214 "private_message": false, 215 "status": "replied", 216 "intervention_id": "7f946431b6eebffafae642cc", 217 "language": "fr", 218 "body": "Hello,\n\nHow to unlock my nokia 3210?\n\nThanks!", 219 "body_formatted": { 220 "text": "Hello,\n\nHow to unlock my nokia 3210?\n\nThanks!", 221 "html": "<p>Hello,</p>\n\n<p>How to unlock my nokia 3210?</p>\n\n<p>Thanks!</p>" 222 }, 223 "body_input_format": "text", 224 "title": "Nokia 3210 unlocking", 225 "attachments_count": 1, "attachments": [{ 226 "id":"5464b5c04d61639684110000", "created_at":"2011-05-05T22:00:00Z", 227 "updated_at":"2011-05-05T22:00:00Z", 228 "content_type": "application/pdf", "size": 174784, 229 "filename":"sso.pdf", 230 "foreign_id":"123", 231 "embed":"false", 232 "public?":"true", 233 "url":"h​ ttp://domain-test.engagement.dimelo.dev/attachments/5464b5c04d61639684110000​" 234 }], 235 "synchronization_status": "success", 236 "category_ids": [ 237 "4d0fb475b242228033cbdf6d", "60944e5702bdafb74ac96141"], 238 "created_at": "2012-05-24T04:00:44Z", 239 "updated_at": "2012-05-24T04:00:44Z", 240 "approval_required": false, 241 "remotely_deleted": false, 242 "published": true, 243 "context_data": { 244 "customer_id": 1214 245 } 246 } 247 ' 248 properties = {} 249 250 object = MultiJson.load doc 251 252 object.each do |name,v| 253 prop = { 254 type: 'string' 255 } 256 if v =~ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/ 257 prop[:format] = 'date-time' 258 end 259 260 if !!v == v 261 prop[:type] = 'boolean' 262 elsif v.is_a? Integer 263 prop[:type] = 'integer' 264 end 265 if v.kind_of?(Array) 266 prop[:type] = 'array' 267 prop[:items] = { type: "string" } 268 end 269 270 properties[name] = prop 271 end 272 273 puts doc 274 275 puts MultiJson.dump properties, pretty: true