Class: Twtxt::Yarn::Session
- Inherits:
-
Object
- Object
- Twtxt::Yarn::Session
- Includes:
- HTTParty, Twtxt::Yarn
- Defined in:
- lib/twtxt/yarn.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#get_profile(username) ⇒ Object
def get_profile_twts(username, page) self.class.get(“#@endpoint/profile/#username/twts?page=#page”, headers: @headers) end.
- #get_twtxt(profile) ⇒ Object
-
#initialize(credentials) ⇒ Session
constructor
A new instance of Session.
- #ping ⇒ Object
- #post_twt(twt_text) ⇒ Object
- #whoami ⇒ Object
Methods included from Twtxt::Yarn
api_endpoint, #authenticated_headers, get_jwt_token, yarn_twtxt_link
Constructor Details
#initialize(credentials) ⇒ Session
Returns a new instance of Session.
43 44 45 46 47 48 |
# File 'lib/twtxt/yarn.rb', line 43 def initialize(credentials) @credentials = credentials @endpoint = api_endpoint(credentials.yarnpod) @token = get_jwt_token(credentials.username, credentials.password, self.endpoint) @headers = authenticated_headers(self.token) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
41 42 43 |
# File 'lib/twtxt/yarn.rb', line 41 def credentials @credentials end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
41 42 43 |
# File 'lib/twtxt/yarn.rb', line 41 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
41 42 43 |
# File 'lib/twtxt/yarn.rb', line 41 def headers @headers end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
41 42 43 |
# File 'lib/twtxt/yarn.rb', line 41 def token @token end |
Instance Method Details
#get_profile(username) ⇒ Object
def get_profile_twts(username, page)
self.class.get("#{@endpoint}/profile/#{username}/twts?page=#{page}", headers: @headers)
end
70 71 72 |
# File 'lib/twtxt/yarn.rb', line 70 def get_profile(username) self.class.get("#{@endpoint}/profile/#{username}", headers: @headers) end |
#get_twtxt(profile) ⇒ Object
74 75 76 |
# File 'lib/twtxt/yarn.rb', line 74 def get_twtxt(profile) self.class.get("https://#{credentials.yarnpod}/user/#{profile}/twtxt.txt", headers: @headers) end |
#ping ⇒ Object
50 51 52 |
# File 'lib/twtxt/yarn.rb', line 50 def ping self.class.get("#{@endpoint}/ping", headers: @headers) end |
#post_twt(twt_text) ⇒ Object
78 79 80 |
# File 'lib/twtxt/yarn.rb', line 78 def post_twt(twt_text) self.class.post("#{@endpoint}/post", body: { text: twt_text, post_as: "#{@credentials.username}" }.to_json, headers: @headers) end |
#whoami ⇒ Object
54 55 56 |
# File 'lib/twtxt/yarn.rb', line 54 def whoami self.class.get("#{@endpoint}/whoami", headers: @headers) end |