bskyrb 0.2.1 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. metadata +4 -5
  3. data/lib/bskyrb.rb +0 -103
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa3ecd9b24a2ae044cfcc5ff1825f0f28f903089f62e6961b2c4404e1b24864c
4
- data.tar.gz: e171427efd25ba3cc22e8deb0c3e1819c6bc0b3131d985a367e4349c77b905bc
3
+ metadata.gz: d3ebcdf8ed7dabe9c22cf650ffecec5c8883d72b32c29baae4a44f40f94365bd
4
+ data.tar.gz: d3ad042fa4d4a1b2e62e53ca2aae552078b7aa3f78f1c612b1a6fc568f3b0c61
5
5
  SHA512:
6
- metadata.gz: 93d1ad04723d948e14e63fdbefcb902bb81448707018a1d8bf0344ec5aac46176bc1db5fc482f267456eaf0b7adf8daf116adff1e29496975ba106ce6974c15a
7
- data.tar.gz: d6eeb0e934ef49a29f58ea4eaba92d131b4c37f6277bc6becbe390f96f9797fd0617a2d163070ac117de38ec0eafdddeba8410ccd720f172aad16af8e79a2342
6
+ metadata.gz: 8e6ab71de741b377398c4a651d3b34406b0f1c0fa3d5c1d9c3721976dacec12146ecf8900a9a33a38feaf75f2db45320723e5f1967587456d1200b16d2fe7130
7
+ data.tar.gz: a022a0f04a37a4c4be4dab37fa9a9d2e348f3ff0c541ae02a8422ec3149d466d900465c90f834c0811163b12f43fde4789288607ce7d1a2faf0b4b2fc7efcaed
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bskyrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shreyan Jain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 1980-01-01 00:00:00.000000000 Z
11
+ date: 2023-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -72,8 +72,7 @@ email:
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
- files:
76
- - lib/bskyrb.rb
75
+ files: []
77
76
  homepage: https://github.com/ShreyanJain9/bskyrb
78
77
  licenses:
79
78
  - MIT
@@ -93,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
92
  - !ruby/object:Gem::Version
94
93
  version: '0'
95
94
  requirements: []
96
- rubygems_version: 3.3.20
95
+ rubygems_version: 3.4.10
97
96
  signing_key:
98
97
  specification_version: 4
99
98
  summary: Interact with bsky/atproto using Ruby
data/lib/bskyrb.rb DELETED
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # require_relative "bskyrb/version"
4
- require 'json'
5
- require 'net/http'
6
- require 'httparty'
7
- require 'date'
8
- module ATProto
9
- class Session
10
- def initialize(username, password, pds)
11
- @atp_host = pds
12
- @atp_auth_token = ""
13
- @did = ""
14
- @username = username
15
- # headers = { "Content-Type" => "application/json" }
16
- data = { "identifier" => username, "password" => password }.to_json
17
-
18
- uri = URI("#{@atp_host}/xrpc/com.atproto.server.createSession")
19
- response = Net::HTTP.post(uri, data, 'Content-Type' => 'application/json')
20
- # response = HTTParty.post(uri, body: data.to_json, headers: {'Content-Type' => 'application/json'} )
21
-
22
- parsed_response = JSON.parse(response.body)
23
-
24
- @atp_auth_token = parsed_response['accessJwt']
25
-
26
- if @atp_auth_token.nil?
27
- raise ValueError.new("No access token, is your password wrong?")
28
- end
29
-
30
- @did = parsed_response['did']
31
- end
32
- def getdid()
33
- return @did
34
- end
35
-
36
- def resolveHandle(username)
37
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => "application/json" }
38
- response = HTTParty.get("#{@atp_host}/xrpc/com.atproto.identity.resolveHandle?handle=#{username}", headers: headers)
39
-
40
- return response.body
41
- end
42
- def get_skoot_by_url(url)
43
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => "application/json" }
44
-
45
- username_of_person_in_link = url.split('/')[-3]
46
- did_of_person_in_link = JSON.parse(resolveHandle(username_of_person_in_link))['did']
47
- url_identifier = url.split('/')[-1]
48
-
49
- uri = "at://#{did_of_person_in_link}/app.bsky.feed.post/#{url_identifier}"
50
-
51
- response = HTTParty.get("#{@atp_host}/xrpc/app.bsky.feed.getPostThread?uri=#{uri}", headers: headers)
52
-
53
- return response
54
- end
55
-
56
- def uploadBlob(blob_path, content_type)
57
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => content_type }
58
- image_bytes = File.binread(blob_path)
59
-
60
- uri = URI("#{@atp_host}/xrpc/com.atproto.repo.uploadBlob")
61
- response = HTTParty.post("#{@atp_host}/xrpc/com.atproto.repo.uploadBlob", body: image_bytes, headers: headers)
62
-
63
- return response
64
- end
65
-
66
-
67
- def post(postcontent)
68
- timestamp = DateTime.now.iso8601(3)
69
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => "application/json" }
70
-
71
- data = {
72
- "collection" => "app.bsky.feed.post",
73
- "$type" => "app.bsky.feed.post",
74
- "repo" => "#{@did}",
75
- "record" => {
76
- "$type" => "app.bsky.feed.post",
77
- "createdAt" => timestamp,
78
- "text" => postcontent
79
- }
80
- }
81
-
82
- uri = URI("#{@atp_host}/xrpc/com.atproto.repo.createRecord")
83
-
84
-
85
- resp = HTTParty.post(
86
- uri,
87
- body: data.to_json,
88
- headers: headers
89
- )
90
- # response = Net::HTTP.post(uri, data.to_json, headers)
91
- return resp
92
- end
93
-
94
- def method_missing(method_name, *args)
95
- message = "You called #{method_name} with #{args}. This method doesn't exist."
96
-
97
- raise NoMethodError, message
98
-
99
- end
100
- end
101
- end
102
-
103
-