Skip to content
This repository
Browse code

[enhance] twitter: Added help.

  • Loading branch information...
commit bd2f385ea639f9d133f913f799ac48d0a9b056f1 1 parent 0691ea5
Norman Scaife nrs135 authored

Showing 1 changed file with 104 additions and 0 deletions. Show diff stats Hide diff stats

  1. +104 0 lib/stdlib/apis/twitter/twitter.opa
104 lib/stdlib/apis/twitter/twitter.opa
@@ -524,6 +524,33 @@ type Twitter.saved_search = {
524 524 query : string
525 525 }
526 526
  527 +type Twitter.size = {
  528 + h : int
  529 + w : int
  530 + resize : string
  531 +}
  532 +
  533 +type Twitter.config = {
  534 + characters_reserved_per_media : int
  535 + max_media_per_upload : int
  536 + non_username_paths : list(string)
  537 + photo_size_limit : int
  538 + photo_sizes: {
  539 + large: Twitter.size
  540 + medium: Twitter.size
  541 + small: Twitter.size
  542 + thumb: Twitter.size
  543 + }
  544 + short_url_length : int
  545 + short_url_length_https : int
  546 +}
  547 +
  548 +type Twitter.lang = {
  549 + code : string
  550 + name : string
  551 + status : string
  552 +}
  553 +
527 554 /**
528 555 * @author Nicolas Glondu, March 2010
529 556 * @category Twitter ?
@@ -1093,6 +1120,49 @@ type Twitter.saved_search = {
1093 1120 _build_query_result(s) =
1094 1121 _check_errors(s, get_query_result)
1095 1122
  1123 + get_size(json) =
  1124 + map = JsonOpa.record_fields(json) ? Map.empty
  1125 + {
  1126 + h = get_int("h", map)
  1127 + w = get_int("w", map)
  1128 + resize = get_string("resize", map)
  1129 + } : Twitter.size
  1130 +
  1131 + get_sizes(json) =
  1132 + map = JsonOpa.record_fields(json) ? Map.empty
  1133 + {
  1134 + large = get_obj("large", map, get_size)
  1135 + medium = get_obj("medium", map, get_size)
  1136 + small = get_obj("small", map, get_size)
  1137 + thumb = get_obj("thumb", map, get_size)
  1138 + }
  1139 +
  1140 + get_config(json) =
  1141 + map = JsonOpa.record_fields(json) ? Map.empty
  1142 + {
  1143 + characters_reserved_per_media = get_int("characters_reserved_per_media", map)
  1144 + max_media_per_upload = get_int("max_media_per_upload", map)
  1145 + non_username_paths = get_list("non_username_paths", map, get_json_string)
  1146 + photo_size_limit = get_int("photo_size_limit", map)
  1147 + photo_sizes = get_obj("photo_sizes", map, get_sizes)
  1148 + short_url_length = get_int("short_url_length", map)
  1149 + short_url_length_https = get_int("short_url_length_https", map)
  1150 + } : Twitter.config
  1151 +
  1152 + _build_config(s) =
  1153 + _check_errors(s, get_config)
  1154 +
  1155 + get_lang(json) =
  1156 + map = JsonOpa.record_fields(json) ? Map.empty
  1157 + {
  1158 + code = get_string("code", map)
  1159 + name = get_string("name", map)
  1160 + status = get_string("status", map)
  1161 + } : Twitter.lang
  1162 +
  1163 + _build_langs(s) =
  1164 + _check_errors(s, get_raw_list(_, get_lang))
  1165 +
1096 1166 _simple_decoder(data) =
1097 1167 decode_data =
1098 1168 [ ("\\u00e9", "é"), ("\\u00e8", "è"), ("\\u00e0", "à"),
@@ -2730,4 +2800,38 @@ Twitter(conf:Twitter.configuration) = {{
2730 2800 |> add_if("callback", callback, (_!=""))
2731 2801 Twitter_private(c)._post_res(path, params, credentials, TwitParse._build_place)
2732 2802
  2803 +/**
  2804 + * Report spam
  2805 + *
  2806 + * The user specified in the id is blocked by the authenticated user and reported as a spammer.
  2807 + *
  2808 + * @param user The screen name or the unique id of the requested user.
  2809 + */
  2810 + report_spam(user, credentials) =
  2811 + path = "/1.1/users/report_spam.json"
  2812 + params = add_user(user, [])
  2813 + Twitter_private(c)._post_res(path, params, credentials, TwitParse._build_full_user)
  2814 +
  2815 +/**
  2816 + * Help configuration
  2817 + *
  2818 + * Returns the current configuration used by Twitter including twitter.com slugs which are not usernames, maximum photo resolutions, and t.co URL lengths.
  2819 + *
  2820 + */
  2821 + help_configuration(credentials) =
  2822 + path = "/1.1/help/configuration.json"
  2823 + params = []
  2824 + Twitter_private(c)._post_res(path, params, credentials, TwitParse._build_config)
  2825 +
  2826 +/**
  2827 + * Help languages
  2828 + *
  2829 + * Returns the list of languages supported by Twitter along with their ISO 639-1 code.
  2830 + *
  2831 + */
  2832 + help_languages(credentials) =
  2833 + path = "/1.1/help/languages.json"
  2834 + params = []
  2835 + Twitter_private(c)._post_res(path, params, credentials, TwitParse._build_langs)
  2836 +
2733 2837 }}

0 comments on commit bd2f385

Please sign in to comment.
Something went wrong with that request. Please try again.