Skip to content

Commit

Permalink
dartfmt retry
Browse files Browse the repository at this point in the history
  • Loading branch information
sh4869 committed Aug 30, 2015
1 parent 1cdd119 commit e03b01b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
9 changes: 0 additions & 9 deletions lib/src/client.dart
Expand Up @@ -3,35 +3,26 @@
library twitter.client;

import 'dart:async';

import 'dart:convert';

import 'package:http/http.dart' as http;

import 'package:oauth/oauth.dart' as oauth;

class Client extends oauth.Client {

/// Constructs a new Client with [oauth.Tokens]
Client(oauth.Tokens tokens) : super(tokens);

/// Send an HTTP request and Return [http.Response] with the given headers and body to the given
/// URL, which can be a [Uri] or a [String] and [method].
///
Future<http.Response> request(String method, url,
{Map<String, String> headers, body, Encoding encoding}) {
if (url is String) url = Uri.parse(url);

var request = new http.Request(method, url);

if (headers != null) request.headers.addAll(headers);

if (encoding != null) request.encoding = encoding;

if (body != null) {
if (body is String) {
request.body = body;
Expand Down
16 changes: 0 additions & 16 deletions lib/twitter.dart
Expand Up @@ -3,59 +3,43 @@ library twitter;
import 'dart:async';

import 'package:oauth/oauth.dart' as oauth;

import 'package:http/http.dart' as http;

import 'src/client.dart';

/// A Class for Twitter
class Twitter {

/// Twitter API Endpoint
final String baseUrl = 'https://api.twitter.com/1.1/';

/// oauth.Tokens for [Client]
oauth.Tokens oauthTokens;

/// An HTTP Client
Client twitterClient;

Twitter._internal(this.oauthTokens, this.twitterClient);

/// Creates a new [Twitter] instance from [consumerKey],[consumerSecret],[accessToken],[accessSecret]
///
factory Twitter(String consumerKey, String consumerSecret, String accessToken,
String accessSecret) {
oauth.Tokens oauthTokens = new oauth.Tokens(
consumerId: consumerKey,
consumerKey: consumerSecret,
userId: accessToken,
userKey: accessSecret);

Client twitterClient = new Client(oauthTokens);

return new Twitter._internal(oauthTokens, twitterClient);
}

/// send a request to Twitter
///
/// [method] is HTTP method name, for example "GET" , "POST".
/// [endPoint] is REST API Name of Twitter. for example "statuses/mentions_timeline.json".
/// [body] is HTTP Request's body.
Future<http.Response> request(String method, String endPoint, {Map body}) {
var requestUrl = baseUrl + endPoint;

return twitterClient.request(method, requestUrl, body: body);
}
}

0 comments on commit e03b01b

Please sign in to comment.