Skip to content

Commit

Permalink
merge and update Import and Export
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmdrz committed Aug 8, 2018
2 parents 3a217dd + 8a4b107 commit 4eb2917
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
10 changes: 9 additions & 1 deletion account.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ type Account struct {
// Sync updates account information
func (account *Account) Sync() error {
insta := account.inst
body, err := insta.sendSimpleRequest(urlUserByID, account.ID)
data, err := insta.prepareData()
if err != nil {
return err
}
body, err := insta.sendRequest(&reqOptions{
Endpoint: urlCurrentUser,
Query: generateSignature(data),
IsPost: true,
})
if err == nil {
resp := profResp{}
err = json.Unmarshal(body, &resp)
Expand Down
14 changes: 9 additions & 5 deletions goinsta.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ func (inst *Instagram) UnsetProxy() {
}

// Save exports config to ~/.goinsta
func (inst *Instagram) Save() {
home := os.Getenv("$HOME")
func (inst *Instagram) Save() error {
home := os.Getenv("HOME")
if home == "" {
home = os.Getenv("$home") // for plan9
home = os.Getenv("home") // for plan9
}
inst.Export(filepath.Join(home, ".goinsta"))
return inst.Export(filepath.Join(home, ".goinsta"))
}

// Export exports *Instagram object options
Expand Down Expand Up @@ -369,7 +369,7 @@ func (inst *Instagram) Login() error {
if err != nil {
return err
}
_, err = inst.sendRequest(
body, err := inst.sendRequest(
&reqOptions{
Endpoint: urlLogin,
Query: generateSignature(b2s(result)),
Expand All @@ -384,6 +384,10 @@ func (inst *Instagram) Login() error {

// getting account data
res := accountResp{}
err = json.Unmarshal(body, &res)
if err != nil {
return err
}

inst.Account = &res.Account
inst.Account.inst = inst
Expand Down
5 changes: 5 additions & 0 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func (users *Users) Next() bool {
return false
}

// Error returns users error
func (users *Users) Error() error {
return users.err
}

func (users *Users) setValues() {
for i := range users.Users {
users.Users[i].inst = users.inst
Expand Down

0 comments on commit 4eb2917

Please sign in to comment.